1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703
|
-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries
--
-- SmartEiffel is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License, as published by the
-- Free Software Foundation; either version 2, or (at your option) any later
-- version.
-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-- more details. You should have received a copy of the GNU General Public
-- License along with SmartEiffel; see the file COPYING. If not, write to
-- the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-- MA 02111-1307, USA.
--
-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.
-- - University of Nancy 1 - FRANCE
-- Copyright(C) 2003: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne
-- - University of Nancy 2 - FRANCE
--
-- Dominique COLNET, Suzanne COLLIN, Olivier ZENDRA,
-- Philippe RIBET, Cyril ADRIAN
--
-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
--
class NATIVE_SMART_EIFFEL
inherit NATIVE
creation make, default_create
feature
need_prototype: BOOLEAN is False
stupid_switch_function(run_time_set: RUN_TIME_SET; name: STRING)
: BOOLEAN is
do
if name.has_prefix(fz_basic_) then
Result := True
elseif as_character_bits = name or else
as_generating_type = name or else
as_generator = name or else
as_to_pointer = name or else
as_item = name
then
Result := True
end
end
stupid_switch_procedure(run_time_set: RUN_TIME_SET; name: STRING)
: BOOLEAN is
do
if name.has_prefix(fz_basic_) then
Result := True
elseif as_call = name then
Result := True
end
end
notify_external_assignments(args: FORMAL_ARG_LIST; rt: E_TYPE) is
do
end
c_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
local
ct: E_TYPE
do
if as_bit_n = bcn then
c_define_procedure_bit(rf7,name)
elseif as_copy = name or else as_standard_copy = name then
ct := rf7.current_type
if ct.is_reference and then ace.no_check then
rf7.c_define_with_body(once "memcpy(C,a1,sizeof(*C));%N")
elseif ct.is_user_expanded then
if ct.is_dummy_expanded then
rf7.c_define_with_body(once "/*No fields.*/%N")
else
rf7.c_define_with_body(once "memcpy(C,&a1,sizeof(*C));%N")
end
end
end
end
c_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
local
ct: E_TYPE; cbd: BOOLEAN
do
ct := rf7.current_type
if name.has_prefix(fz_basic_) then
cbd := cpp.target_cannot_be_dropped
if cbd then cpp.put_character(',') end
cpp.put_string(name)
if rf7.arguments /= Void then
cpp.put_character('(')
cpp.put_arguments
cpp.put_character(')')
end
if cbd then cpp.put_character(')') end
cpp.put_string(fz_00)
elseif as_copy = name or else as_standard_copy = name then
if ct.is_reference then
if ace.boost then
cpp.put_string(once "*((T"); cpp.put_integer(ct.id)
cpp.put_string(once "*)(")
cpp.put_target_as_value
cpp.put_string(once "))=*((T"); cpp.put_integer(ct.id)
cpp.put_string(once "*)(")
cpp.put_ith_argument(1)
cpp.put_string(once "));%N")
else
rf7.default_mapping_procedure
end
elseif ct.is_basic_eiffel_expanded then
cpp.put_target_as_value
cpp.put_string(fz_00)
cpp.put_ith_argument(1)
cpp.put_string(fz_00)
else
rf7.default_mapping_procedure
end
elseif as_print_run_time_stack = name then
if smart_eiffel.scoop then
cpp.put_string(once "se_current_subsystem_thread()->vft.print_run_time_stack(se_current_subsystem_thread());%N")
else
cpp.put_string(once "se_print_run_time_stack();%N")
end
elseif as_print_all_run_time_stacks = name then
cpp.put_string(once "se_print_run_time_stack();%N")
elseif as_die_with_code = name then
if cpp.target_cannot_be_dropped then
cpp.put_string(fz_14)
end
cpp.put_string(once "exit(")
cpp.put_ith_argument(1)
cpp.put_string(fz_14)
elseif as_native_array = bcn then
c_mapping_native_array_procedure(rf7,name)
elseif as_bit_n = bcn then
c_mapping_bit_procedure(rf7,name)
elseif is_integer(ct) then
c_mapping_integer_procedure(rf7,name)
elseif as_raise_exception = name then
cpp.put_string(once "internal_exception_handler(")
cpp.put_ith_argument(1)
cpp.put_string(fz_14)
elseif as_full_collect = name then
if not gc_handler.is_off then
cpp.put_string(once "gc_start();%N")
end
elseif as_c_inline_c = name then
cpp.put_c_inline_c
elseif as_c_inline_h = name then
cpp.put_c_inline_h
elseif as_trace_switch = name then
cpp.put_trace_switch
elseif as_sedb_breakpoint = name then
cpp.put_sedb_breakpoint
elseif as_collection_off = name then
if not gc_handler.is_off then
cpp.put_string(once "gc_is_off=1;%N")
end
elseif as_collection_on = name then
if not gc_handler.is_off then
cpp.put_string(fz_48)
end
elseif as_put_16_be = name or else
as_put_16_le = name or else
as_put_16_ne = name then
cpp.put_string(once "*((int16_t*)(")
cpp.put_ith_argument(1)
cpp.put_string(once "+")
cpp.put_ith_argument(3)
cpp.put_string(once "))=")
if as_put_16_ne /= name then
if as_put_16_be = name then
cpp.put_string(once "%N#if BYTE_ORDER == LITTLE_ENDIAN%N")
else
cpp.put_string(once "%N#if BYTE_ORDER == BIG_ENDIAN%N")
end
cpp.put_character('(')
cpp.put_ith_argument(2)
cpp.put_string(once "<<8)|((uint16_t)")
cpp.put_ith_argument(2)
cpp.put_string(once ">>8);%N")
cpp.put_string(once "#else%N")
end
cpp.put_ith_argument(2)
cpp.put_string(once ";%N")
if as_put_16_ne /= name then
cpp.put_string(once "#endif%N")
end
else
check False end
end
end
scoop_define_function_body(rf8: RUN_FEATURE_8; bcn, name: STRING) is
-- Produce C code to define the corresponding `rf8' body.
-- (Or nothing when the code is inlined.)
require
rf8.base_feature.first_name.to_string = name
rf8.base_feature.base_class.name.to_string = bcn
rf8.arguments.has_like_current
rf8.current_type.is_separate
do
if as_is_equal = name or else as_standard_is_equal = name then
cpp.put_string(
once "[
R=((C->id==a1->id)?
!memcmp(C->ref,((sT0*)a1)->ref,sizeof(*(C->ref)))
:0);
]")
elseif as_is_deep_equal = name then
body.clear
rf8.run_class.is_deep_equal_in(body)
cpp.put_string(body)
end
end
scoop_define_procedure_body(rf7: RUN_FEATURE_7; bcn, name: STRING) is
-- Produce C code to define the corresponding `rf7' body.
-- (Or nothing when the code is inlined.)
require
rf7.base_feature.first_name.to_string = name
rf7.base_feature.base_class.name.to_string = bcn
rf7.arguments.has_like_current
rf7.current_type.is_separate
local
t: E_TYPE
do
if as_copy = name or else as_standard_copy = name then
cpp.put_string(once "*(C->ref)=*((T")
cpp.put_integer(t.id)
cpp.put_string(fz_70)
cpp.put_ith_argument(1)
cpp.put_string(once ")->ref);%N")
end
end
c_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
local
elt_type: E_TYPE; ct: E_TYPE; rc: RUN_CLASS
rf: RUN_FEATURE; rf7: RUN_FEATURE_7; ref_type: TYPE_REFERENCE
do
ct := rf8.current_type
ref_type ?= ct
rc := rf8.run_class
if as_bit_n = bcn then
c_define_function_bit(rf8,name)
elseif as_is_equal = name or else as_standard_is_equal = name then
rc := rf8.run_class
if ct.is_basic_eiffel_expanded then
elseif ct.is_native_array then
elseif ct.is_bit then
elseif ref_type /= Void and then
ref_type.expanded_type.is_basic_eiffel_expanded
then
body.copy(once "R=(T6)((C->_item)==(((T")
ref_type.id.append_in(body)
body.append(once "*)a1)->_item));")
rf8.c_define_with_body(body)
elseif rc.is_tagged then
rf8.c_define_with_body(
once "R=(T6)((C->id==a1->id)?!memcmp(C,a1,sizeof(*C)):0);")
elseif rc.writable_attributes = Void then
if ace.boost then
else
rf8.c_define_with_body(fz_92)
end
elseif ace.boost then
else
rf8.c_define_with_body(once "R=(T6)!memcmp(C,&a1,sizeof(*C));")
end
elseif as_standard_twin = name then
c_define_standard_twin(rf8,rf8.current_type)
elseif as_twin = name then
rf := rc.get_copy
rf7 ?= rf
if rf7 /= Void then
c_define_standard_twin(rf8,ct)
else
c_define_twin(rf8,ct,rc,rf)
end
elseif as_deep_twin = name then
if ct.is_basic_eiffel_expanded or else ct.is_dummy_expanded then
rf8.c_define_with_body(once "R=C;%N")
elseif ct.is_native_array then
error_handler.add_type(ct,fz_dtideena)
error_handler.print_as_warning
if ace.boost then
rf8.c_define_with_body(once "R=NULL")
else
rf8.c_define_with_body(
once "error0(%"Invalid deep_twin.%",NULL);")
end
else
body.clear
rf8.run_class.deep_twin_in(body)
rf8.c_define_with_body(body)
end
elseif as_is_deep_equal = name then
if ct.is_basic_eiffel_expanded then
rf8.c_define_with_body(once "R=(T6)(C==a1);%N")
elseif ct.is_dummy_expanded then
rf8.c_define_with_body(once "R=1;%N")
elseif ct.is_native_array then
error_handler.add_type(ct,fz_dtideena)
error_handler.print_as_warning
if ace.boost then
rf8.c_define_with_body(once "R=0")
else
rf8.c_define_with_body(
once "error0(%"Invalid is_deep_equal.%",NULL);")
end
else
body.clear
rf8.run_class.is_deep_equal_in(body)
rf8.c_define_with_body(body)
end
elseif as_native_array = bcn then
if as_calloc = name then
elt_type := ct.generic_list.item(1).run_type
if expanded_initializer(elt_type) then
body.clear
body.append(once "R=")
if gc_handler.is_off then
body.append(once "se_malloc(sizeof(T")
elt_type.id.append_in(body)
body.append(once ")*")
else
body.append(once "(void*)new")
ct.id.append_in(body)
body.extend('(')
end
body.append(once "a1);%Nr")
ct.id.append_in(body)
body.append(once "clear_all(")
if ace.no_check then
body.append(fz_85)
end
body.append(once "R,a1-1);%N")
rf8.c_define_with_body(body)
end
end
elseif is_integer(ct) then
if as_to_integer_8 = name then
c_define_integer_to_integer(8, rf8)
elseif as_to_integer_16 = name then
c_define_integer_to_integer(16, rf8)
elseif as_to_integer_32 = name then
c_define_integer_to_integer(32, rf8)
end
end
end
c_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
local
cbd, cda: BOOLEAN; ct: E_TYPE; rc: RUN_CLASS; rf: RUN_FEATURE
rf7: RUN_FEATURE_7; basic_eq: BOOLEAN; type_bit: TYPE_BIT
do
ct := rf8.current_type
if name.has_prefix(fz_basic_) then
cbd := cpp.target_cannot_be_dropped
if cbd then cpp.put_character(',') end
cpp.put_string(name)
if rf8.arguments /= Void then
cpp.put_character('(')
cpp.put_arguments
cpp.put_character(')')
end
if cbd then cpp.put_character(')') end
elseif as_platform = bcn then
cbd := cpp.target_cannot_be_dropped
if cbd then cpp.put_character(',') end
tmp_string.copy(once "EIF_")
tmp_string.append(name)
tmp_string.to_upper
cpp.put_string(tmp_string)
if cbd then cpp.put_character(')') end
elseif as_generating_type = name then
cpp.put_generating_type(ct)
elseif as_generator = name then
cpp.put_generator(ct)
elseif as_same_dynamic_type = name then
cpp.put_comment(as_same_dynamic_type)
if ct.is_reference and then ct.run_class.is_tagged then
cpp.put_string(once "((")
if ace.no_check then cpp.put_string(once "(vc(") end
cpp.put_string(once "((T0*)(")
cpp.put_target_as_value
cpp.put_string(once "))")
if ace.no_check then cpp.put_string(once ",0))") end
cpp.put_string(once "->id)==(")
if ace.no_check then cpp.put_string(once "(vc(") end
cpp.put_string(once "((T0*)(")
cpp.put_ith_argument(1)
cpp.put_string(once "))")
if ace.no_check then cpp.put_string(once ",0))") end
cpp.put_string(once "->id))")
else -- Statically known:
cda := cpp.cannot_drop_all
if cda then cpp.put_character(',') end
cpp.put_character('1')
if cda then cpp.put_character(')') end
end
elseif as_to_pointer = name then
cpp.put_string(once "((void*)(")
cpp.put_target_as_value
if ct.is_expanded and then not ct.is_native_array then
error_handler.add_position(rf8.start_position)
error_handler.append(once "Bad usage of GENERAL.to_pointer.")
cpp.target_position_in_error_handler
error_handler.print_as_warning
cpp.put_string(once ",NULL")
end
cpp.put_string(fz_13)
elseif as_object_size = name then
cpp.put_object_size(ct)
elseif as_is_equal = name or else as_standard_is_equal = name then
rc := rf8.run_class
if ct.is_basic_eiffel_expanded then
basic_eq := True
elseif ct.is_native_array then
basic_eq := True
elseif ct.is_bit then
type_bit ?= ct
basic_eq := not type_bit.is_c_unsigned_ptr
end
if basic_eq then
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character(')')
cpp.put_string(fz_c_eq)
cpp.put_character('(')
exp_or_ref(ct, 1)
cpp.put_character(')')
elseif rc.is_tagged then
rf8.default_mapping_function
elseif rc.writable_attributes = Void then
if ace.boost then
cbd := cpp.cannot_drop_all
if cbd then
cpp.put_character(',')
end
cpp.put_character('1')
if cbd then
cpp.put_character(')')
end
else
rf8.default_mapping_function
end
elseif ace.boost then
cpp.put_string(once "!memcmp(")
cpp.put_target_as_target
cpp.put_character(',')
if ct.is_user_expanded then
cpp.put_character('&')
end
cpp.put_character('(')
cpp.put_ith_argument(1)
cpp.put_string(fz_84)
cpp.put_integer(rc.id)
cpp.put_string(fz_13)
else
rf8.default_mapping_function
end
elseif as_standard_twin = name then
c_mapping_standard_twin(rf8, ct)
elseif as_twin = name then
rc := rf8.run_class
rf := rc.get_copy
rf7 ?= rf
if rf7 /= Void then
c_mapping_standard_twin(rf8,ct)
else
rf8.default_mapping_function
end
elseif as_deep_twin = name then
if ct.is_basic_eiffel_expanded then
cpp.put_target_as_target
elseif ct.is_user_expanded then
rf8.default_mapping_function
else
cpp.put_string(
once "(se_deep_twin_start(),se_deep_twin_trats(")
rf8.default_mapping_function
cpp.put_string(fz_13)
end
elseif as_is_deep_equal = name then
rf8.default_mapping_function
elseif as_is_basic_expanded_type = name then
cbd := cpp.cannot_drop_all
if cbd then
cpp.put_character(',')
end
if ct.is_basic_eiffel_expanded then
cpp.put_character('1')
else
cpp.put_character('0')
end
if cbd then
cpp.put_character(')')
end
elseif as_is_expanded_type = name then
cbd := cpp.cannot_drop_all
if cbd then
cpp.put_character(',')
end
if ct.is_expanded then
cpp.put_character('1')
else
cpp.put_character('0')
end
if cbd then
cpp.put_character(')')
end
elseif as_se_argc = name then
cpp.put_string(as_se_argc)
elseif as_se_argv = name then
cpp.put_string(once "((T0*)se_string(se_argv[_i]))")
elseif as_native_array = bcn then
c_mapping_native_array_function(rf8,name)
elseif as_real = bcn or else as_double = bcn then
c_mapping_real_double(ct, name, rf8.arg_count)
elseif as_boolean = bcn then
if as_implies = name then
cpp.put_string(once "(T6)((!(")
exp_or_ref(ct, 0)
cpp.put_string(once "))||(")
exp_or_ref(ct, 1)
cpp.put_string(once "))")
else
check rf8.arg_count = 1 end
cpp.put_string(once "(T6)((")
exp_or_ref(ct, 0)
if as_or_else = name then
cpp.put_string(once ")||(")
else
check as_and_then = name end
cpp.put_string(fz_39)
end
exp_or_ref(ct, 1)
cpp.put_string(once "))")
end
elseif as_character = bcn then
cpp.put_string(once "T3")
cpp.put_string(name)
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_pointer = bcn then
check as_is_not_null = name end
cpp.put_string(once "(NULL!=")
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_bit_n = bcn then
c_mapping_bit_function(rf8,name)
elseif as_pointer_size = name then
cpp.put_string(fz_sizeof)
cpp.put_character('(')
cpp.put_string(fz_t0_star)
cpp.put_character(')')
elseif as_exception = name then
cpp.put_string(once "internal_exception_number")
elseif as_signal_number = name then
cpp.put_string(once "signal_exception_number")
elseif as_collecting = name then
if gc_handler.is_off then
cpp.put_character('0')
else
cpp.put_string(once "!gc_is_off")
end
elseif as_collector_counter = name then
if gc_handler.is_off then
cpp.put_string(once "(-1)")
else
cpp.put_string(as_collector_counter)
end
elseif is_integer(ct) then
c_mapping_integer_function(rf8,name)
elseif as_as_16_ne = name then
cpp.put_string(once "%N#if BYTE_ORDER == LITTLE_ENDIAN%N(")
cpp.put_ith_argument(2)
cpp.put_string(once "<<8)|((uint16_t)")
cpp.put_ith_argument(1)
cpp.put_string(once ")%N#else%N(")
cpp.put_ith_argument(1)
cpp.put_string(once "<<8)|((uint16_t)")
cpp.put_ith_argument(2)
cpp.put_string(once ")%N#endif%N")
else
check False end
end
end
jvm_add_method_for_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
local
ct: E_TYPE; rc: RUN_CLASS; rf: RUN_FEATURE; rf7: RUN_FEATURE_7
writable_attribute: WRITABLE_ATTRIBUTE; rf2: RUN_FEATURE_2
feature_name: FEATURE_NAME; feature_name_list: FEATURE_NAME_LIST
t_pointer: TYPE_POINTER; t_integer: TYPE_INTEGER
t_native_array: TYPE_NATIVE_ARRAY
do
if as_twin = name then
ct := rf8.current_type
rc := rf8.run_class
rf := rc.get_copy
rf7 ?= rf
if rf7 = Void then
jvm.add_method(rf8)
end
elseif as_generating_type = name then
jvm.add_method(rf8)
elseif as_generator = name then
jvm.add_method(rf8)
elseif bcn = as_native_array then
elseif as_item = name then
-- creation of agent class, including attribute definitions
if not jvm.has_method_name( as_item ) then
jvm.add_method(rf8)
create feature_name.simple_feature_name( as_target, rf8.start_position )
create feature_name_list.make_1( feature_name )
create t_pointer.make( rf8.start_position)
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_arguments, rf8.start_position )
create feature_name_list.make_1( feature_name )
create t_native_array.make( rf8.start_position, t_pointer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_open_arguments, rf8.start_position )
create feature_name_list.make_1( feature_name )
create t_native_array.make( rf8.start_position, t_pointer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_open_argument_indices, rf8.start_position )
create feature_name_list.make_1( feature_name )
create t_integer.integer( rf8.start_position )
create t_native_array.make( rf8.start_position, t_integer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_last_result, rf8.start_position )
create feature_name_list.make_1( feature_name )
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_method, rf8.start_position )
create feature_name_list.make_1( feature_name )
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
end
end
end
jvm_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
local
ct: E_TYPE; rc: RUN_CLASS; rf: RUN_FEATURE; rf7: RUN_FEATURE_7
rc_idx, field_idx, point1: INTEGER; cp: like constant_pool
ca: like code_attribute; index_args: INTEGER
t_pointer: TYPE_POINTER
do
cp := constant_pool
ca := code_attribute
if as_twin = name then
ct := rf8.current_type
rc := rf8.run_class
rf := rc.get_copy
rf7 ?= rf
if rf7 /= Void then
else
jvm_define_twin(rf8,rc,rf)
end
elseif as_generating_type = name then
rf8.jvm_opening
ct := rf8.current_type
rc := rf8.run_class
rc_idx := rc.jvm_constant_pool_index
field_idx := cp.idx_fieldref_generating_type(rc_idx)
ca.opcode_getstatic(field_idx,1)
ca.opcode_dup
point1 := ca.opcode_ifnonnull
ca.opcode_pop
ca.opcode_push_manifest_string(ct.run_time_mark)
ca.opcode_dup
ca.opcode_putstatic(field_idx,-1)
ca.resolve_u2_branch(point1)
rf8.jvm_closing_fast
elseif as_generator = name then
rf8.jvm_opening
ct := rf8.current_type
rc := rf8.run_class
rc_idx := rc.jvm_constant_pool_index
field_idx := cp.idx_fieldref_generator(rc_idx)
ca.opcode_getstatic(field_idx,1)
ca.opcode_dup
point1 := ca.opcode_ifnonnull
ca.opcode_pop
ca.opcode_push_manifest_string(ct.base_class_name.to_string)
ca.opcode_dup
ca.opcode_putstatic(field_idx,-1)
ca.resolve_u2_branch(point1)
rf8.jvm_closing_fast
elseif as_function = bcn then
if as_call = name then
create t_pointer.make( rf8.start_position)
rf8.jvm_opening
index_args := code_attribute.extra_local( t_pointer )
code_attribute.opcode_iconst_1
code_attribute.opcode_pop
rf8.jvm_closing
end
end
end
jvm_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
local
ct: E_TYPE; rc: RUN_CLASS; rf: RUN_FEATURE; rf7: RUN_FEATURE_7
point1, point2, space, idx: INTEGER; cp: like constant_pool
ca: like code_attribute
do
ct := rf8.current_type
ca := code_attribute
cp := constant_pool
if name.has_prefix(fz_basic_) then
jvm.drop_target
jvm_smart_eiffel_runtime(name,rf8)
elseif as_to_pointer = name then
jvm.push_target
elseif is_integer(ct) then
jvm_mapping_integer_function(rf8,name)
elseif as_real = bcn then
jvm_mapping_real_function(rf8,name)
elseif as_double = bcn then
jvm_mapping_double_function(rf8,name)
elseif as_native_array = bcn then
jvm_mapping_native_array_function(rf8,name)
elseif as_character = bcn then
if as_code = name then
jvm.push_target
ca.opcode_dup
point1 := ca.opcode_ifge
ca.opcode_sipush(255)
ca.opcode_iand
ca.resolve_u2_branch(point1)
elseif as_to_integer = name then
jvm.push_target
else
check
as_to_bit = name
end
jvm_int_to_bit(rf8.result_type,8)
end
elseif as_is_not_null = name then
jvm.push_target
point1 := ca.opcode_ifnonnull
ca.opcode_iconst_0
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
ca.resolve_u2_branch(point2)
elseif as_implies = name then
jvm.push_target
point1 := ca.opcode_ifeq
space := jvm.push_ith_argument(1)
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
ca.resolve_u2_branch(point2)
elseif as_generating_type = name then
rf8.routine_mapping_jvm
elseif as_generator = name then
rf8.routine_mapping_jvm
elseif as_to_pointer = name then
fe_nyi(rf8)
elseif as_object_size = name then
jvm.drop_target
jvm_object_size(ct)
elseif as_is_equal = name or else as_standard_is_equal = name then
jvm.push_target
space := jvm.push_ith_argument(1)
rf8.current_type.jvm_standard_is_equal
elseif as_standard_twin = name then
jvm_standard_twin(rf8.current_type)
elseif as_twin = name then
rc := rf8.run_class
rf := rc.get_copy
rf7 ?= rf
if rf7 /= Void then
jvm_standard_twin(ct)
else
rf8.routine_mapping_jvm
end
elseif as_is_basic_expanded_type = name then
jvm.drop_target
if rf8.current_type.is_basic_eiffel_expanded then
ca.opcode_iconst_1
else
ca.opcode_iconst_0
end
elseif as_is_expanded_type = name then
jvm.drop_target
if rf8.current_type.is_expanded then
ca.opcode_iconst_1
else
ca.opcode_iconst_0
end
elseif as_se_argc = name then
jvm.push_se_argc
elseif as_se_argv = name then
jvm.push_se_argv
elseif as_platform = bcn then
jvm.drop_target
if as_character_bits = name then
ca.opcode_bipush(8)
elseif as_integer_bits = name then
ca.opcode_bipush(32)
elseif as_boolean_bits = name then
ca.opcode_bipush(32)
elseif as_real_bits = name then
ca.opcode_bipush(32)
elseif as_double_bits = name then
ca.opcode_bipush(64)
elseif as_pointer_bits = name then
ca.opcode_bipush(32)
elseif as_minimum_character_code = name then
ca.opcode_iconst_i(0)
elseif as_minimum_double = name then
idx := cp.idx_fieldref3(fz_java_lang_double,
fz_max_value,fz_77)
ca.opcode_getstatic(idx,2)
ca.opcode_dneg
elseif as_minimum_real = name then
idx := cp.idx_fieldref3(fz_java_lang_float,fz_max_value,fz_78)
ca.opcode_getstatic(idx,1)
ca.opcode_fneg
elseif as_maximum_character_code = name then
ca.opcode_sipush(255)
elseif as_maximum_double = name then
idx := cp.idx_fieldref3(fz_java_lang_double,fz_max_value,fz_77)
ca.opcode_getstatic(idx,2)
end
elseif as_pointer_size = name then
ca.opcode_bipush(32)
elseif as_bit_n = bcn then
jvm_mapping_bit_function(rf8,name)
elseif as_item = name then
jvm.push_target
rc := rf8.run_class
idx := rc.jvm_constant_pool_index
idx := cp.idx_fieldref4(idx,as_item,fz_a9)
ca.opcode_getfield(idx,0)
elseif as_exception = name then
ca.runtime_internal_exception_number
elseif as_signal_number = name then
else
fe_nyi(rf8)
end
end
jvm_add_method_for_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
local
writable_attribute: WRITABLE_ATTRIBUTE
rf2: RUN_FEATURE_2
feature_name: FEATURE_NAME
feature_name_list: FEATURE_NAME_LIST
t_pointer: TYPE_POINTER
t_integer: TYPE_INTEGER
t_native_array: TYPE_NATIVE_ARRAY
do
if as_procedure = bcn or as_routine = bcn then
if as_call = name then -- creation of agent class, including attribute definitions
if jvm.has_method_name( as_call ) = False then
jvm.add_method(rf7)
create feature_name.simple_feature_name( as_target, rf7.start_position )
create feature_name_list.make_1( feature_name )
create t_pointer.make( rf7.start_position)
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_arguments, rf7.start_position )
create feature_name_list.make_1( feature_name )
create t_native_array.make( rf7.start_position, t_pointer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_open_arguments, rf7.start_position )
create feature_name_list.make_1( feature_name )
create t_native_array.make( rf7.start_position, t_pointer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_open_argument_indices, rf7.start_position )
create feature_name_list.make_1( feature_name )
create t_integer.integer( rf7.start_position)
create t_native_array.make( rf7.start_position, t_integer)
create writable_attribute.make( feature_name_list, t_native_array )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_last_result, rf7.start_position )
create feature_name_list.make_1( feature_name )
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
create feature_name.simple_feature_name( as_method, rf7.start_position )
create feature_name_list.make_1( feature_name )
create writable_attribute.make( feature_name_list, t_pointer )
rf2 := writable_attribute.to_run_feature( t_pointer, feature_name )
jvm.add_field( rf2 )
end
end
end
end
jvm_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
local
t_pointer: TYPE_POINTER; index_args: INTEGER
do
if as_procedure = bcn then
if as_call = name then
create t_pointer.make( rf7.start_position)
rf7.jvm_opening
index_args := code_attribute.extra_local( t_pointer )
code_attribute.opcode_iconst_0
code_attribute.opcode_pop
rf7.jvm_closing
end
end
end
jvm_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
local
ct: E_TYPE; ca: like code_attribute; cp: like constant_pool
space: INTEGER;
do
ct := rf7.current_type
ca := code_attribute
cp := constant_pool
if name.has_prefix(fz_basic_) then
jvm.drop_target
jvm_smart_eiffel_runtime(name,rf7)
elseif as_copy = name or else as_standard_copy = name then
if ct.is_basic_eiffel_expanded then
jvm.drop_target
jvm.drop_ith_argument(1)
else
jvm_copy(rf7.current_type)
end
elseif as_die_with_code = name then
jvm.drop_target
space := jvm.push_ith_argument(1)
ca.runtime_die_with_code
elseif as_print_run_time_stack = name then
jvm_smart_eiffel_runtime(name,rf7)
elseif as_print_all_run_time_stacks = name then
jvm_smart_eiffel_runtime(name,rf7)
elseif as_sedb_breakpoint = name then
elseif as_native_array = bcn then
jvm_mapping_native_array_procedure(rf7,name)
elseif as_raise_exception = name then
fe_nyi(rf7)
elseif as_bit_n = bcn then
jvm_mapping_bit_procedure(rf7,name)
elseif is_integer(ct) then
jvm_mapping_integer_procedure(rf7,name)
else
fe_nyi(rf7)
end
end
feature
use_current(er: EXTERNAL_ROUTINE): BOOLEAN is
local
name: STRING
do
name := er.first_name.to_string
if name.has_prefix(fz_basic_) then
elseif as_se_argc = name then
elseif as_se_argv = name then
else
Result := True
end
end
feature {NONE}
jvm_smart_eiffel_runtime(name: STRING; rf: RUN_FEATURE) is
-- Call the corresponding sys/SmartEiffelRutime.java static
-- definition of some external "SmartEiffel" feature.
local
idx, space: INTEGER; fal: FORMAL_ARG_LIST; rt: E_TYPE
prototype: STRING
do
fal := rf.arguments
rt := rf.result_type
jvm.drop_target
if fal /= Void then
space := - jvm.push_arguments
end
prototype := once "(....)."
prototype.clear
prototype.extend('(')
if fal /= Void then
fal.jvm_descriptor_in(prototype)
end
prototype.extend(')')
if rt = Void then
prototype.extend('V')
else
rt.jvm_descriptor_in(prototype)
space := space + rt.jvm_stack_space
end
idx := constant_pool.idx_methodref3(basic_java_class(name), name, prototype)
code_attribute.opcode_invokestatic(idx,space)
end
jvm_object_size(ct: E_TYPE) is
local
t: E_TYPE
space, i: INTEGER
wa: ARRAY[RUN_FEATURE_2]
do
if ct.is_basic_eiffel_expanded then
space := ct.jvm_stack_space
else
wa := ct.run_class.writable_attributes
if wa /= Void then
from
i := wa.upper
until
i = 0
loop
t := wa.item(i).result_type
space := space + t.jvm_stack_space
i := i - 1
end
end
end
code_attribute.opcode_push_integer(space)
end
basic_java_class(name: STRING): STRING is
-- Examples:
-- basic_pointer_to_any => SmartEiffelBasicPointer
-- basic_time_mktime => SmartEiffelBasicTime
local
i, n: INTEGER
capitalize: BOOLEAN
c: CHARACTER
do
Result := tmp_string
Result.copy(once "fr/loria/smarteiffel/")
if name.has_prefix(fz_basic_) then
n := name.index_of('_', fz_basic_.count+1) - 1
if n = 0 then
n := name.count
end
Result.append(once "SmartEiffel")
from
i := 1
capitalize := true
until
i > n
loop
c := name.item(i)
if c = '_' then
capitalize := true
elseif capitalize then
Result.extend(c.to_upper)
capitalize := false
else
Result.extend(c)
end
i := i + 1
end
else
Result.append(fz_se_runtime)
end
end
c_mapping_standard_twin(rf8: RUN_FEATURE_8; ct: E_TYPE) is
do
if ct.is_basic_eiffel_expanded then
cpp.put_target_as_value
elseif ct.is_expanded then
if ct.is_dummy_expanded then
cpp.put_target_as_target
elseif ct.is_native_array then
cpp.put_target_as_target
else
rf8.default_mapping_function
end
else
rf8.default_mapping_function
end
end
c_define_standard_twin(rf8: RUN_FEATURE_8; ct: E_TYPE) is
do
if ct.is_basic_eiffel_expanded then
elseif ct.is_expanded then
if ct.is_dummy_expanded then
elseif ct.is_native_array then
else
rf8.c_define_with_body(once "memcpy(&R,C,sizeof(R));")
end
else
if gc_handler.is_off then
body.copy(once "R=se_malloc(sizeof(*C));%N")
else
body.copy(once "R=(")
body.append(fz_cast_void_star)
ct.gc_call_new_in(body)
body.append(fz_14)
end
body.append(fz_69)
ct.id.append_in(body)
body.append(once "*)R)=*C;%N")
rf8.c_define_with_body(body)
end
end
c_define_twin(rf8: RUN_FEATURE_8; ct: E_TYPE; rc: RUN_CLASS
cpy: RUN_FEATURE) is
require
rf8 /= Void
ct.is_reference or ct.is_user_expanded
rc = ct.run_class
cpy /= Void
local
id: INTEGER
do
rf8.c_opening
if ct.is_reference then
if gc_handler.is_off then
id := rc.id
cpp.put_string(once "R=se_malloc(sizeof(*C));%N")
cpp.put_string(fz_69)
cpp.put_integer(id)
cpp.put_string(once "*)R)=M")
cpp.put_integer(id)
cpp.put_string(fz_00)
else
body.copy(once "R=((void*)")
ct.gc_call_new_in(body)
body.append(fz_14)
cpp.put_string(body)
end
end
cpp.inside_twin(cpy)
rf8.c_closing
end
jvm_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
local
elt_type: E_TYPE
space: INTEGER
rc: RUN_CLASS
loc1, point1, point2: INTEGER
ca: like code_attribute
do
elt_type := rf8.current_type.generic_list.item(1).run_type
if as_element_sizeof = name then
jvm.drop_target
space := elt_type.jvm_stack_space
code_attribute.opcode_push_integer(space)
elseif as_item = name then
jvm.push_target
space := jvm.push_ith_argument(1)
elt_type.jvm_xaload
elseif as_calloc = name then
jvm.drop_target
space := jvm.push_ith_argument(1)
elt_type.jvm_xnewarray
if elt_type.is_user_expanded and then
not elt_type.is_dummy_expanded
then
ca := code_attribute
rc := elt_type.run_class
loc1 := ca.extra_local_size1
ca.opcode_dup
ca.opcode_arraylength
ca.opcode_istore(loc1)
point1 := ca.program_counter
ca.opcode_iload(loc1)
point2 := ca.opcode_ifle
ca.opcode_iinc(loc1,255)
ca.opcode_dup
ca.opcode_iload(loc1)
rc.jvm_expanded_push_default
ca.opcode_aastore
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
end
elseif name = as_from_pointer then
jvm.drop_target
space := jvm.push_ith_argument(1)
rf8.run_class.opcode_checkcast
else
fe_nyi(rf8)
end
end
jvm_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
local
elt_type: E_TYPE
space: INTEGER
rc: RUN_CLASS
flag: BOOLEAN
wa: ARRAY[RUN_FEATURE_2]
do
elt_type := rf7.current_type.generic_list.item(1).run_type
check
as_put = name
end
rc := elt_type.run_class
flag := rc.run_time_mark.has_substring("NATIVE_ARRAY")
if elt_type.is_basic_eiffel_expanded or elt_type.is_reference or flag then
jvm.push_target
space := jvm.push_ith_argument(2)
space := jvm.push_ith_argument(1)
elt_type.jvm_xastore
else
jvm.push_target
space := jvm.push_ith_argument(2)
elt_type.jvm_xaload
space := jvm.push_ith_argument(1)
wa := rc.writable_attributes
jvm.fields_by_fields_expanded_copy(wa)
code_attribute.opcode_pop2
end
end
c_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
local
ct, elt_type: E_TYPE; tcbd: BOOLEAN
do
ct := rf8.current_type
elt_type := ct.generic_list.item(1).run_type
if as_element_sizeof = name then
tcbd := cpp.target_cannot_be_dropped
if tcbd then
cpp.put_character(',')
end
tmp_string.copy(fz_sizeof)
tmp_string.extend('(')
elt_type.c_type_for_argument_in(tmp_string)
tmp_string.extend(')')
cpp.put_string(tmp_string)
if tcbd then
cpp.put_character(')')
end
elseif as_calloc = name then
if expanded_initializer(elt_type) then
rf8.default_mapping_function
else
tcbd := cpp.target_cannot_be_dropped
if tcbd then
cpp.put_character(',')
end
if gc_handler.is_off then
cpp.put_string(fz_b7)
cpp.put_integer(ct.id)
cpp.put_string(once ")(se_calloc(")
cpp.put_ith_argument(1)
tmp_string.copy(once ",sizeof(")
elt_type.c_type_for_result_in(tmp_string)
tmp_string.append(once "))))")
cpp.put_string(tmp_string)
else
cpp.put_string(fz_new)
cpp.put_integer(rf8.current_type.id)
cpp.put_character('(')
cpp.put_ith_argument(1)
cpp.put_character(')')
end
if tcbd then
cpp.put_character(')')
end
end
elseif as_from_pointer = name then
tcbd := cpp.target_cannot_be_dropped
if tcbd then
cpp.put_character(',')
end
cpp.put_ith_argument(1)
if tcbd then
cpp.put_character(')')
end
elseif as_item = name then
cpp.put_character('(')
cpp.put_target_as_value
cpp.put_string(fz_46)
cpp.put_ith_argument(1)
cpp.put_character(']')
else
error_handler.append(once "Class NATIVE_ARRAY has been tampered with.%
% Unknown function: ")
error_handler.append(name)
error_handler.add_position(rf8.start_position)
error_handler.print_as_fatal_error
end
end
c_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
local
elt_type: E_TYPE
do
elt_type := rf7.current_type.generic_list.item(1).run_type
if name = as_put then
if elt_type.is_user_expanded then
if elt_type.is_dummy_expanded then
if cpp.cannot_drop_all then
cpp.put_string(fz_14)
end
else
cpp.put_string(once "{%NT")
cpp.put_integer(elt_type.id)
cpp.put_string(once " tmp_src=")
cpp.put_ith_argument(1)
cpp.put_string(once ";%Nmemcpy((")
cpp.put_target_as_value
cpp.put_string(once ")+(")
cpp.put_ith_argument(2)
cpp.put_string(once "),&(tmp_src),sizeof(T")
cpp.put_integer(elt_type.id)
cpp.put_string(once "));%N}%N")
end
else
cpp.put_character('(')
cpp.put_target_as_value
cpp.put_string(fz_46)
cpp.put_ith_argument(2)
cpp.put_string(once "]=(")
cpp.put_ith_argument(1)
cpp.put_string(fz_14)
end
else
error_handler.append(once "Class NATIVE_ARRAY has been tampered with.%
% Unknown procedure: ")
error_handler.append(name)
error_handler.add_position(rf7.start_position)
error_handler.print_as_fatal_error
end
end
jvm_copy(t: E_TYPE) is
require
not t.is_basic_eiffel_expanded
local
rc: RUN_CLASS
wa: ARRAY[RUN_FEATURE_2]
space: INTEGER
do
rc := t.run_class
wa := rc.writable_attributes
jvm.push_target
space := jvm.push_ith_argument(1)
rc.opcode_checkcast
jvm.fields_by_fields_copy(wa)
code_attribute.opcode_pop
end
jvm_define_twin(rf8: RUN_FEATURE_8; rc: RUN_CLASS; cpy: RUN_FEATURE) is
require
rc = rf8.run_class
cpy /= Void
local
idx, space, i: INTEGER
wa: ARRAY[RUN_FEATURE_2]
rf2: RUN_FEATURE_2
do
rf8.jvm_opening
wa := rc.writable_attributes
rc.jvm_basic_new
code_attribute.opcode_astore_1
if wa /= Void then
from
i := wa.upper
until
i = 0
loop
rf2 := wa.item(i)
code_attribute.opcode_aload_1
idx := constant_pool.idx_fieldref(rf2)
space := rf2.result_type.jvm_push_default
code_attribute.opcode_putfield(idx,-(space + 1))
i := i - 1
end
end
jvm.inside_twin(cpy)
rf8.jvm_closing
end
feature {NONE}
jvm_standard_twin(t: E_TYPE) is
require
t /= Void
local
rc: RUN_CLASS
wa: ARRAY[RUN_FEATURE_2]
do
if t.is_basic_eiffel_expanded or else t.is_native_array then
jvm.push_target
else
rc := t.run_class
wa := rc.writable_attributes
if t.is_expanded then
if wa = Void then
jvm.push_target
else
jvm_standard_twin_aux(rc,wa)
end
else
jvm_standard_twin_aux(rc,wa)
end
end
end
jvm_standard_twin_aux(rc: RUN_CLASS; wa: ARRAY[RUN_FEATURE_2]) is
require
rc /= Void
local
ca: like code_attribute
rf2: RUN_FEATURE_2
idx, space, i: INTEGER
do
ca := code_attribute
rc.jvm_basic_new
if wa = Void then
jvm.drop_target
else
jvm.push_target
rc.opcode_checkcast
from
i := wa.upper
until
i = 0
loop
rf2 := wa.item(i)
ca.opcode_dup2
idx := constant_pool.idx_fieldref(rf2)
space := rf2.result_type.jvm_stack_space
ca.opcode_getfield(idx,space - 1)
ca.opcode_putfield(idx,space + 1)
i := i - 1
end
ca.opcode_pop
end
end
jvm_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
local
point1, point2, space: INTEGER; ca: like code_attribute
do
ca := code_attribute
if as_slash = name then
jvm.push_target
ca.opcode_i2d
space := jvm.push_ith_argument(1)
ca.opcode_i2d
ca.opcode_ddiv
elseif as_bit_rotate = name then
space := jvm.push_ith_argument(1)
point1 := ca.opcode_iflt
jvm.push_target
space := jvm.push_ith_argument(1)
ca.opcode_iushr
jvm.push_target
ca.opcode_bipush(32)
space := jvm.push_ith_argument(1)
ca.opcode_isub
ca.opcode_ishl
ca.opcode_ior
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
jvm.push_target
space := jvm.push_ith_argument(1)
ca.opcode_ineg
ca.opcode_ishl
jvm.push_target
ca.opcode_bipush(32)
space := jvm.push_ith_argument(1)
ca.opcode_iadd
ca.opcode_iushr
ca.opcode_ior
ca.resolve_u2_branch(point2)
elseif rf8.arg_count = 1 then
jvm.push_target
space := jvm.push_ith_argument(1)
if as_plus_native = name then
ca.opcode_iadd
elseif as_minus_native = name then
ca.opcode_isub
elseif as_muls_native = name then
ca.opcode_imul
elseif as_slash_slash = name then
ca.opcode_idiv
elseif as_backslash_backslash = name then
ca.opcode_irem
elseif as_shift_right = name then
ca.opcode_ishr
elseif as_bit_shift_right_unsigned = name then
ca.opcode_iushr
elseif as_shift_left = name then
ca.opcode_ishl
elseif as_bit_rotate_right = name then
ca.opcode_iushr
jvm.push_target
ca.opcode_bipush(32)
space := jvm.push_ith_argument(1)
ca.opcode_isub
ca.opcode_ishl
ca.opcode_ior
elseif as_bit_rotate_left = name then
ca.opcode_ishl
jvm.push_target
ca.opcode_bipush(32)
space := jvm.push_ith_argument(1)
ca.opcode_isub
ca.opcode_iushr
ca.opcode_ior
elseif as_bit_and = name then
ca.opcode_iand
elseif as_bit_or = name then
ca.opcode_ior
elseif as_bit_xor = name then
ca.opcode_ixor
else -- < > <= >= only
if as_gt = name then
point1 := ca.opcode_if_icmpgt
elseif as_lt = name then
point1 := ca.opcode_if_icmplt
elseif as_le = name then
point1 := ca.opcode_if_icmple
else
point1 := ca.opcode_if_icmpge
end
ca.opcode_iconst_0
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
ca.resolve_u2_branch(point2)
end
elseif as_to_character = name then
jvm.push_target
code_attribute.opcode_i2b
elseif as_to_bit = name then
jvm_int_to_bit(rf8.result_type,32)
elseif as_minus = name then
jvm.push_target
code_attribute.opcode_ineg
elseif as_bit_not = name then
jvm.push_target
ca.opcode_iconst_m1
ca.opcode_ixor
elseif as_low_8 = name then
jvm.push_target
ca.opcode_sipush(255)
ca.opcode_iand
elseif as_low_16 = name then
jvm.push_target
ca.opcode_i2s
elseif as_low_32 = name then
jvm.push_target
ca.opcode_l2i
else
jvm.push_target
end
end
jvm_mapping_integer_procedure(rf7: RUN_FEATURE_7; name: STRING) is
local
point1, point2, space: INTEGER
ca: like code_attribute
do
ca := code_attribute
if as_bit_put = name then
space := jvm.push_ith_argument(1)
point1 := ca.opcode_ifeq
ca.opcode_iconst_1
space := jvm.push_ith_argument(2)
ca.opcode_ishl
jvm.push_target
ca.opcode_ior;
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
space := jvm.push_ith_argument(2)
ca.opcode_ishl
ca.opcode_iconst_m1
ca.opcode_ixor
jvm.push_target
ca.opcode_iand;
ca.resolve_u2_branch(point2)
jvm.assign_target
elseif as_bit_set = name then
ca.opcode_iconst_1
space := jvm.push_ith_argument(1)
ca.opcode_ishl
jvm.push_target
ca.opcode_ior;
jvm.assign_target
elseif as_bit_clear = name then
ca.opcode_iconst_1
space := jvm.push_ith_argument(1)
ca.opcode_ishl
ca.opcode_iconst_m1
ca.opcode_ixor
jvm.push_target
ca.opcode_iand;
jvm.assign_target
end
end
jvm_mapping_real_function(rf8: RUN_FEATURE_8; name: STRING) is
local
point1, point2, space: INTEGER
ca: like code_attribute
do
ca := code_attribute
if rf8.arg_count = 1 then
jvm.push_target
space := jvm.push_ith_argument(1)
if as_plus = name then
ca.opcode_fadd
elseif as_minus = name then
ca.opcode_fsub
elseif as_muls = name then
ca.opcode_fmul
elseif as_slash = name then
ca.opcode_fdiv
else
ca.opcode_fcmpg
if as_gt = name then -- gt
point1 := ca.opcode_ifgt
elseif as_lt = name then -- lt
point1 := ca.opcode_iflt
elseif as_le = name then -- le
point1 := ca.opcode_ifle
elseif as_ge = name then -- ge
point1 := ca.opcode_ifge
end
ca.opcode_iconst_0
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
ca.resolve_u2_branch(point2)
end
elseif as_minus = name then
jvm.push_target
ca.opcode_fneg
elseif as_to_double = name then
jvm.push_target
ca.opcode_f2d
end
end
jvm_mapping_double_function(rf8: RUN_FEATURE_8; name: STRING) is
local
point1, point2, space, idx: INTEGER
ca: like code_attribute
do
ca := code_attribute
if rf8.arg_count = 1 then
jvm.push_target
space := jvm.push_ith_argument(1)
if as_plus = name then
ca.opcode_dadd
elseif as_minus = name then
ca.opcode_dsub
elseif as_muls = name then
ca.opcode_dmul
elseif as_slash = name then
ca.opcode_ddiv
elseif as_pow = name then
idx := constant_pool.idx_methodref3(fz_java_lang_math,
as_pow_postfix,fz_99)
ca.opcode_i2d
ca.opcode_invokestatic(idx,-2)
elseif as_pow_postfix = name then
idx := constant_pool.idx_methodref3(fz_java_lang_math,
as_pow_postfix,fz_99)
ca.opcode_invokestatic(idx,-2)
elseif as_atan2 = name then
idx := constant_pool.idx_methodref3(fz_java_lang_math,
as_atan2,fz_99)
ca.opcode_invokestatic(idx,-2)
else
ca.opcode_dcmpg
if as_gt = name then -- gt
point1 := ca.opcode_ifgt
elseif as_lt = name then -- lt
point1 := ca.opcode_iflt
elseif as_le = name then -- le
point1 := ca.opcode_ifle
elseif as_ge = name then -- ge
point1 := ca.opcode_ifge
end
ca.opcode_iconst_0
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
ca.opcode_iconst_1
ca.resolve_u2_branch(point2)
end
elseif as_minus = name then
jvm.push_target
ca.opcode_dneg
elseif as_to_real = name then
jvm.push_target
ca.opcode_d2f
elseif as_double_floor = name then
jvm.push_target
idx := constant_pool.idx_methodref3(fz_java_lang_math,
as_floor, fz_94)
ca.opcode_invokestatic(idx,0)
elseif as_truncated_to_integer = name then
jvm.push_target
idx := constant_pool.idx_methodref3(fz_java_lang_math,
as_floor, fz_94)
ca.opcode_invokestatic(idx,0)
ca.opcode_d2i
else -- Same name in java/lang/Math :
jvm.push_target
idx := constant_pool.idx_methodref3(fz_java_lang_math,name,fz_94)
ca.opcode_invokestatic(idx,0)
end
end
feature {NATIVE_SMART_EIFFEL_VISITOR}
accept(visitor: NATIVE_SMART_EIFFEL_VISITOR) is
do
visitor.visit_native_smart_eiffel(Current)
end
feature {NONE}
to_integer(size: INTEGER; no_check: BOOLEAN) is
do
if no_check then
cpp.put_character('R')
cpp.put_character('=')
end
cpp.put_string(once "((EIF_INTEGER_")
cpp.put_integer(size)
cpp.put_character(')')
if no_check then
cpp.put_character('C')
else
cpp.put_character('(')
cpp.put_target_as_value
cpp.put_character(')')
end
cpp.put_character(')')
if no_check then cpp.put_string(fz_00) end
end
c_define_integer_to_integer(size: INTEGER; rf8: RUN_FEATURE_8) is
do
if ace.no_check then
rf8.c_opening
to_integer(size, True)
rf8.c_closing
end
end
c_mapping_integer_to_integer(size: INTEGER; rf8: RUN_FEATURE_8) is
do
if ace.no_check then
rf8.default_mapping_function
else
to_integer(size, False)
end
end
exp_or_ref(ct: E_TYPE; rank: INTEGER) is
require
rank = 0 or rank = 1
local
ref_type: TYPE_REFERENCE; id: INTEGER
do
ref_type ?= ct
if ref_type /= Void then
id := ref_type.id
cpp.put_string(once "((T")
cpp.put_integer(id)
cpp.put_string(once "*)(")
if ace.no_check then
cpp.put_string(once "vc((T0*)(")
end
end
inspect
rank
when 0 then
cpp.put_target_as_value
when 1 then
cpp.put_ith_argument(1)
end
if ref_type /= Void then
if ace.no_check then
cpp.put_string(once "),0)")
end
cpp.put_string(once "))->_item")
end
end
c_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
local
ct: E_TYPE;
do
ct := rf8.current_type
if as_to_integer_8 = name then
c_mapping_integer_to_integer(8, rf8)
elseif as_to_integer_16 = name then
c_mapping_integer_to_integer(16, rf8)
elseif as_to_integer_32 = name then
c_mapping_integer_to_integer(32, rf8)
elseif as_shift_right = name then
cpp.put_string("((")
exp_or_ref(ct, 0)
cpp.put_string(once ")>>(")
cpp.put_ith_argument(1)
cpp.put_string(once "))")
elseif as_bit_shift_right_unsigned = name then
cpp.put_string(once "((uint")
cpp.put_integer(integer_size(ct))
cpp.put_string(once "_t)(")
exp_or_ref(ct, 0)
cpp.put_string(once ")>>(")
cpp.put_ith_argument(1)
cpp.put_string(once "))")
elseif as_shift_left = name then
cpp.put_string(once "((")
exp_or_ref(ct, 0)
cpp.put_string(once ")<<(")
cpp.put_ith_argument(1)
cpp.put_string(once "))")
elseif as_bit_rotate = name then
cpp.put_string(once "((")
cpp.put_ith_argument(1)
cpp.put_string(once ">=0)?((T2)(((unsigned int)")
exp_or_ref(ct, 0)
cpp.put_string(once ">>")
cpp.put_ith_argument(1)
cpp.put_string(once "))|(")
exp_or_ref(ct, 0)
cpp.put_string(once "<<(")
cpp.put_integer(Integer_bits)
cpp.put_string(once "-")
cpp.put_ith_argument(1)
cpp.put_string(once "))):((T2)(((unsigned int)")
exp_or_ref(ct, 0)
cpp.put_string(once ">>(")
cpp.put_integer(Integer_bits)
cpp.put_string(once "+")
cpp.put_ith_argument(1)
cpp.put_string(once ")))|(")
exp_or_ref(ct, 0)
cpp.put_string(once "<<-")
cpp.put_ith_argument(1)
cpp.put_string(once ")))")
elseif as_bit_rotate_right = name then
cpp.put_string(once "((T2)(((unsigned int)")
exp_or_ref(ct, 0)
cpp.put_string(once ">>")
cpp.put_ith_argument(1)
cpp.put_string(once "))|(")
exp_or_ref(ct, 0)
cpp.put_string(once "<<(")
cpp.put_integer(Integer_bits)
cpp.put_character('-')
cpp.put_ith_argument(1)
cpp.put_string(once ")))")
elseif as_bit_rotate_left = name then
cpp.put_string(once "((T2)(((unsigned int)")
exp_or_ref(ct, 0)
cpp.put_string(once ">>(")
cpp.put_integer(Integer_bits)
cpp.put_character('-')
cpp.put_ith_argument(1)
cpp.put_string(once ")))|(")
exp_or_ref(ct, 0)
cpp.put_string(once "<<")
cpp.put_ith_argument(1)
cpp.put_string(once "))")
elseif as_bit_and = name then
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character('&')
exp_or_ref(ct, 1)
cpp.put_character(')')
elseif as_bit_or = name then
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character('|')
exp_or_ref(ct, 1)
cpp.put_character(')')
elseif as_bit_xor = name then
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character('^')
exp_or_ref(ct, 1)
cpp.put_character(')')
elseif as_bit_not = name then
cpp.put_string(once "~(")
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_low_8 = name then
cpp.put_string(once "(EIF_INTEGER_8)(")
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_low_16 = name then
cpp.put_string(once "(EIF_INTEGER_16)(")
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_low_32 = name then
cpp.put_string(once "(EIF_INTEGER_32)(")
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif rf8.arg_count = 1 then
if as_slash = name then
cpp.put_string(once "((T5)")
else
cpp.put_string(once "(int")
cpp.put_integer(integer_size(ct))
cpp.put_string(once "_t)(")
end
cpp.put_character('(')
exp_or_ref(ct, 0)
if as_slash = name then
cpp.put_character(')')
end
cpp.put_character(')')
if as_slash_slash = name then
cpp.put_character('/')
elseif as_backslash_backslash = name then
cpp.put_character('%%')
elseif as_plus_native = name then
cpp.put_character('+')
elseif as_minus_native = name then
cpp.put_character('-')
elseif as_muls_native = name then
cpp.put_character('*')
else
cpp.put_string(name)
end
cpp.put_character('(')
exp_or_ref(ct, 1)
cpp.put_character(')')
if as_slash /= name then
cpp.put_character(')')
end
elseif as_to_character = name then
cpp.put_string(once "((T3)(")
exp_or_ref(ct, 0)
cpp.put_string(fz_13)
elseif as_to_bit = name then
exp_or_ref(ct, 0)
else
cpp.put_string(name)
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character(')')
end
end
c_mapping_integer_procedure(rf7: RUN_FEATURE_7; name: STRING) is
do
if as_bit_put = name then
cpp.put_string(once "if(")
cpp.put_ith_argument(1)
cpp.put_string(once "){%N")
cpp.put_target_as_value
cpp.put_character('=')
cpp.put_target_as_value
cpp.put_string(once "|(1<<")
cpp.put_ith_argument(2)
cpp.put_string(once ");%N}%Nelse{%N")
cpp.put_target_as_value
cpp.put_character('=')
cpp.put_target_as_value
cpp.put_string(once "&(~(1<<")
cpp.put_ith_argument(2)
cpp.put_string(once "));%N}")
elseif as_bit_set = name then
cpp.put_target_as_value
cpp.put_character('=')
cpp.put_target_as_value
cpp.put_string(once "|(1<<")
cpp.put_ith_argument(1)
cpp.put_string(once ");%N")
elseif as_bit_clear = name then
cpp.put_target_as_value
cpp.put_character('=')
cpp.put_target_as_value
cpp.put_string(once "&(~(1<<")
cpp.put_ith_argument(1)
cpp.put_string(once "));%N")
end
end
c_mapping_real_double(ct: E_TYPE; name: STRING; arg_count: INTEGER) is
require
arg_count = 0 or arg_count = 1
do
if as_pow = name then
system_tools.add_lib_math
cpp.put_string(once "pow((")
exp_or_ref(ct, 0)
cpp.put_string(once "),(double)(")
cpp.put_arguments
cpp.put_string(fz_13)
elseif as_double_floor = name then
system_tools.add_lib_math
cpp.put_string(as_floor)
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character(')')
elseif as_truncated_to_integer = name then
system_tools.add_lib_math
cpp.put_string(once "((int)floor(")
exp_or_ref(ct, 0)
cpp.put_string(fz_13)
elseif as_to_double = name then
cpp.put_string(fz_43)
exp_or_ref(ct, 0)
cpp.put_string(fz_13)
elseif as_to_real = name then
cpp.put_string(fz_45)
exp_or_ref(ct, 0)
cpp.put_string(fz_13)
elseif name.count <= 2 and then arg_count = 1 then
cpp.put_character('(')
exp_or_ref(ct, 0)
cpp.put_character(')')
cpp.put_string(name)
cpp.put_character('(')
exp_or_ref(ct, 1)
cpp.put_character(')')
else
system_tools.add_lib_math
cpp.put_string(name)
cpp.put_character('(')
exp_or_ref(ct, 0)
if arg_count = 1 then
cpp.put_character(',')
exp_or_ref(ct, 1)
end
cpp.put_character(')')
end
end
c_define_procedure_bit(rf7: RUN_FEATURE_7; n: STRING) is
local
type_bit: TYPE_BIT
do
type_bit ?= rf7.current_type
if as_put_0 = n then
if type_bit.is_c_unsigned_ptr then
body.clear
body_long_bit_put01(type_bit,'&','~','1')
rf7.c_define_with_body(body)
end
elseif as_put_1 = n then
if type_bit.is_c_unsigned_ptr then
body.clear
body_long_bit_put01(type_bit,'|',' ','1')
rf7.c_define_with_body(body)
end
elseif as_put = n then
if type_bit.is_c_unsigned_ptr then
body.clear
body.append(once "if(a1)%N")
body_long_bit_put01(type_bit,'|',' ','2')
body.append(fz_else)
body_long_bit_put01(type_bit,'&','~','2')
rf7.c_define_with_body(body)
end
end
end
tmp_string: STRING is
once
!!Result.make(32)
end
fe_long_bit(rf: RUN_FEATURE) is
do
error_handler.add_position(rf.start_position)
error_handler.append("Sorry, this feature cannot be implemented for ")
error_handler.add_type(rf.current_type,
" (bit string too long). You should probably consider using %
%the BIT_STRING class to work around.")
error_handler.print_as_fatal_error
end
fe_nyi(rf: RUN_FEATURE) is
do
error_handler.add_position(rf.start_position)
error_handler.append("Sorry, but this feature is not yet implemented for %
%Current type ")
error_handler.append(rf.current_type.run_time_mark)
fatal_error(" (if you cannot work around mail %"colnet@loria.fr%").")
end
jvm_bit_to_int(size: INTEGER) is
local
idx: INTEGER
point1, point2: INTEGER
loc1, loc2: INTEGER
ca: like code_attribute
cp: like constant_pool
do
ca := code_attribute
cp := constant_pool
jvm.push_target
loc1 := ca.extra_local_size1
ca.opcode_iconst_0
ca.opcode_istore(loc1)
loc2 := ca.extra_local_size1
ca.opcode_iconst_0
ca.opcode_istore(loc2)
ca.opcode_iconst_1
point1 := ca.program_counter
point2 := ca.opcode_ifeq
ca.opcode_iload(loc2)
ca.opcode_iconst_1
ca.opcode_ishl
ca.opcode_istore(loc2)
ca.opcode_dup
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_get,fz_a3)
ca.opcode_invokevirtual(idx,-1)
ca.opcode_iload(loc2)
ca.opcode_ior
ca.opcode_istore(loc2)
ca.opcode_iinc(loc1,1)
-- ***
-- ca.opcode_dup
-- idx := cp.idx_methodref3(fz_java_util_bitset,once "size",fz_71)
-- ca.opcode_invokevirtual(idx,0)
ca.opcode_push_integer(size)
-- ***
ca.opcode_iload(loc1)
ca.opcode_isub
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
ca.opcode_pop
ca.opcode_iload(loc2)
end
jvm_int_to_bit(type_bit: E_TYPE; nb_bit: INTEGER) is
local
idx: INTEGER
point1, point2, point3: INTEGER
loc1, loc2: INTEGER
ca: like code_attribute
cp: like constant_pool
do
ca := code_attribute
cp := constant_pool
jvm.push_target
loc1 := ca.extra_local_size1
ca.opcode_push_integer(nb_bit)
ca.opcode_istore(loc1)
loc2 := ca.extra_local_size1
idx := type_bit.jvm_push_default
ca.opcode_astore(loc2)
ca.opcode_iconst_1
point1 := ca.program_counter
point2 := ca.opcode_ifeq
ca.opcode_iinc(loc1,255)
ca.opcode_dup
ca.opcode_iconst_1
ca.opcode_iand
point3 := ca.opcode_ifeq
ca.opcode_aload(loc2)
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.resolve_u2_branch(point3)
ca.opcode_iconst_1
ca.opcode_iushr
ca.opcode_iload(loc1)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
ca.opcode_pop
ca.opcode_aload(loc2)
end
jvm_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
local
type_bit: TYPE_BIT
space, idx: INTEGER
point1, point2, point3: INTEGER
loc1, loc2: INTEGER
ca: like code_attribute
cp: like constant_pool
do
ca := code_attribute
cp := constant_pool
type_bit ?= rf8.current_type
if as_count = name then
jvm.drop_target
ca.opcode_push_integer(type_bit.nb)
elseif as_item = name then
jvm.push_target
space := jvm.push_ith_argument(1)
ca.opcode_iconst_1
ca.opcode_isub
idx := cp.idx_methodref3(fz_java_util_bitset,fz_get,fz_a3)
ca.opcode_invokevirtual(idx,-1)
elseif as_shift_right = name then
jvm.push_target
space := jvm.push_ith_argument(1)
loc1 := ca.extra_local_size1
loc2 := ca.extra_local_size1
ca.opcode_istore(loc2)
space := type_bit.jvm_push_default
ca.opcode_swap
ca.opcode_push_integer(type_bit.nb)
ca.opcode_istore(loc1)
ca.opcode_iload(loc1)
ca.opcode_iload(loc2)
ca.opcode_isub
ca.opcode_istore(loc2)
ca.opcode_iload(loc2)
point1 := ca.program_counter
point2 := ca.opcode_ifeq
ca.opcode_iinc(loc1,255)
ca.opcode_iinc(loc2,255)
ca.opcode_dup2
ca.opcode_iload(loc2)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_get,fz_a3)
ca.opcode_invokevirtual(idx,-1)
point3 := ca.opcode_ifne
ca.opcode_pop
ca.opcode_iload(loc2)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point3)
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.opcode_iload(loc2)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
ca.opcode_pop
elseif as_shift_left = name then
jvm.push_target
space := jvm.push_ith_argument(1)
loc1 := ca.extra_local_size1
loc2 := ca.extra_local_size1
ca.opcode_istore(loc1)
space := type_bit.jvm_push_default
ca.opcode_swap
ca.opcode_push_integer(type_bit.nb)
ca.opcode_istore(loc2)
ca.opcode_iload(loc2)
ca.opcode_iload(loc1)
ca.opcode_isub
ca.opcode_istore(loc1)
ca.opcode_iload(loc1)
point1 := ca.program_counter
point2 := ca.opcode_ifeq
ca.opcode_iinc(loc1,255)
ca.opcode_iinc(loc2,255)
ca.opcode_dup2
ca.opcode_iload(loc2)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_get,fz_a3)
ca.opcode_invokevirtual(idx,-1)
point3 := ca.opcode_ifne
ca.opcode_pop
ca.opcode_iload(loc1)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point3)
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.opcode_iload(loc1)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
ca.opcode_pop
elseif as_xor = name then
jvm.push_target
ca.opcode_dup
space := jvm.push_ith_argument(1)
idx := cp.idx_methodref3(fz_java_util_bitset,as_xor,fz_b1)
ca.opcode_invokevirtual(idx,0)
elseif as_or = name then
jvm.push_target
ca.opcode_dup
space := jvm.push_ith_argument(1)
idx := cp.idx_methodref3(fz_java_util_bitset,as_or,fz_b1)
ca.opcode_invokevirtual(idx,0)
elseif as_not = name then
jvm.push_target
loc1 := ca.extra_local_size1
ca.opcode_push_integer(type_bit.nb)
ca.opcode_istore(loc1)
ca.opcode_iload(loc1)
point1 := ca.program_counter
point2 := ca.opcode_ifeq
ca.opcode_iinc(loc1,255)
ca.opcode_dup
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_get,fz_a3)
ca.opcode_invokevirtual(idx,-1)
point3 := ca.opcode_ifne
ca.opcode_dup
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.opcode_iload(loc1)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point3)
ca.opcode_dup
ca.opcode_iload(loc1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.opcode_iload(loc1)
ca.opcode_goto_backward(point1)
ca.resolve_u2_branch(point2)
elseif as_and = name then
jvm.push_target
ca.opcode_dup
space := jvm.push_ith_argument(1)
idx := cp.idx_methodref3(fz_java_util_bitset,as_and,fz_b1)
ca.opcode_invokevirtual(idx,0)
elseif as_last = name then
jvm.push_target
ca.opcode_push_integer(type_bit.nb)
ca.opcode_iconst_1
ca.opcode_isub
idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3)
ca.opcode_invokevirtual(idx,-1)
elseif as_to_character = name then
jvm_bit_to_int(8)
elseif as_to_integer = name then
jvm_bit_to_int(32)
end
end
jvm_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
local
type_bit: TYPE_BIT
space, idx, point1, point2: INTEGER
ca: like code_attribute
cp: like constant_pool
do
ca := code_attribute
cp := constant_pool
type_bit ?= rf7.current_type
if name = as_put_0 then
jvm.push_target
space := jvm.push_ith_argument(1)
ca.opcode_iconst_1
ca.opcode_isub
idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27)
ca.opcode_invokevirtual(idx,-2)
elseif name = as_put_1 then
jvm.push_target
space := jvm.push_ith_argument(1)
ca.opcode_iconst_1
ca.opcode_isub
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
else
check
name = as_put
end
jvm.push_target
space := jvm.push_ith_argument(1)
space := jvm.push_ith_argument(2)
ca.opcode_iconst_1
ca.opcode_isub
ca.opcode_swap
point1 := ca.opcode_ifne
idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27)
ca.opcode_invokevirtual(idx,-2)
point2 := ca.opcode_goto
ca.resolve_u2_branch(point1)
idx := cp.idx_methodref3(fz_java_util_bitset,fz_set,fz_27)
ca.opcode_invokevirtual(idx,-2)
ca.resolve_u2_branch(point2)
end
end
c_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
local
type_bit: TYPE_BIT
do
type_bit ?= rf7.current_type
if name = as_put_0 then
if type_bit.is_c_unsigned_ptr then
rf7.default_mapping_procedure
else
mapping_small_bit_put_0(type_bit,1)
end
elseif name = as_put_1 then
if type_bit.is_c_unsigned_ptr then
rf7.default_mapping_procedure
else
mapping_small_bit_put_1(type_bit,1)
end
else
check
name = as_put
end
if type_bit.is_c_unsigned_ptr then
rf7.default_mapping_procedure
else
cpp.put_string(fz_53)
cpp.put_ith_argument(1)
cpp.put_string(fz_62)
mapping_small_bit_put_1(type_bit,2)
cpp.put_string(fz_67)
mapping_small_bit_put_0(type_bit,2)
cpp.put_string(fz_12)
end
end
end
body_long_bit_put01(type_bit: TYPE_BIT; op1, op2, arg: CHARACTER) is
require
type_bit.is_c_unsigned_ptr
do
body.append(once "{%N%
%unsigned int*ptr=((void*)C);%N%
%int ib=(CHAR_BIT*sizeof(int));%N%
%int widx=((")
type_bit.unsigned_padding.append_in(body)
body.append(once "+a")
body.extend(arg)
body.append(once "-1)/ib);%N%
%int bidx=((a")
body.extend(arg)
body.append(once "-1+")
type_bit.unsigned_padding.append_in(body)
body.append(once ")%%ib)+1;%N%
%int shift=ib-bidx;%N%
%(*(ptr+widx))")
body.extend(op1)
body.append(fz_47)
body.extend(op2)
body.append(once "(((unsigned int)1)<<shift));%N}")
end
mapping_small_bit_put01(type_bit: TYPE_BIT; op1, op2: CHARACTER; arg: INTEGER) is
require
not type_bit.is_c_unsigned_ptr
do
cpp.put_target_as_value
cpp.put_character(op1)
cpp.put_string(fz_47)
cpp.put_character(op2)
cpp.put_string(once "(((unsigned ")
if type_bit.is_c_char then
cpp.put_string(fz_char)
else
cpp.put_string(fz_int)
end
cpp.put_string(once ")1)<<(")
cpp.put_integer(type_bit.nb)
cpp.put_string(fz_37)
cpp.put_ith_argument(arg)
cpp.put_string(once "))));%N")
end
mapping_small_bit_put_1(type_bit: TYPE_BIT; arg: INTEGER) is
require
not type_bit.is_c_unsigned_ptr
do
mapping_small_bit_put01(type_bit,'|',' ',arg)
end
mapping_small_bit_put_0(type_bit: TYPE_BIT; arg: INTEGER) is
require
not type_bit.is_c_unsigned_ptr
do
mapping_small_bit_put01(type_bit,'&','~',arg)
end
c_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
local
type_bit: TYPE_BIT
boost: BOOLEAN
do
type_bit ?= rf8.current_type
boost := ace.boost
if as_count = name then
cpp.put_integer(type_bit.nb)
elseif as_item = name then
if type_bit.is_c_unsigned_ptr then
rf8.default_mapping_function
elseif boost then
cpp.put_string(fz_32)
cpp.put_target_as_target
cpp.put_string(fz_36)
cpp.put_integer(type_bit.nb)
cpp.put_string(fz_37)
cpp.put_arguments
cpp.put_string(once ")))&1)")
else
rf8.default_mapping_function
end
elseif as_shift_right = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
elseif boost then
cpp.put_string(fz_17)
cpp.put_target_as_target
cpp.put_string(fz_36)
cpp.put_ith_argument(1)
cpp.put_string(fz_13)
else
rf8.default_mapping_function
end
elseif as_shift_left = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
elseif boost then
cpp.put_string(fz_17)
cpp.put_target_as_target
cpp.put_string(once ")<<(")
cpp.put_ith_argument(1)
cpp.put_string(fz_13)
else
rf8.default_mapping_function
end
elseif as_xor = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
cpp.put_character('(')
cpp.put_target_as_target
cpp.put_string(once ")^(")
cpp.put_ith_argument(1)
cpp.put_character(')')
end
elseif as_or = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
cpp.put_character('(')
cpp.put_target_as_target
cpp.put_character(')')
cpp.put_character('|')
cpp.put_character('(')
cpp.put_ith_argument(1)
cpp.put_character(')')
end
elseif as_not = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
type_bit.mapping_cast
cpp.put_character('~')
cpp.put_character('(')
cpp.put_target_as_target
cpp.put_character(')')
end
elseif as_and = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
cpp.put_character('(')
cpp.put_target_as_target
cpp.put_character(')')
cpp.put_character('&')
cpp.put_character('(')
cpp.put_ith_argument(1)
cpp.put_character(')')
end
elseif as_last = name then
if type_bit.is_c_unsigned_ptr then
rf8.default_mapping_function
elseif boost then
cpp.put_string(fz_32)
cpp.put_target_as_target
cpp.put_string(once "))&1)")
else
rf8.default_mapping_function
end
elseif as_to_character = name then
cpp.put_target_as_value
elseif as_to_integer = name then
cpp.put_target_as_value
end
end
c_define_function_bit(rf8: RUN_FEATURE_8; name: STRING) is
local
type_bit: TYPE_BIT; no_check: BOOLEAN
do
type_bit ?= rf8.current_type
no_check := ace.no_check
if as_count = name then
elseif as_item = name then
if type_bit.is_c_unsigned_ptr then
body.copy(once "{int ib=(CHAR_BIT*sizeof(int));%N%
%int widx=((")
type_bit.unsigned_padding.append_in(body)
body.append(once "+a1-1)/ib);%N%
%unsigned int word=*(((unsigned int*)C)+widx);%N%
%int bidx=((a1-1+")
type_bit.unsigned_padding.append_in(body)
body.append(once ")%%ib)+1;%N%
%int shift=ib-bidx;%N%
%R=(T6)((word>>shift)&1);%N}%N")
rf8.c_define_with_body(body)
elseif no_check then
body.copy(once "R=(T6)(((unsigned int)C>>(")
type_bit.nb.append_in(body)
body.append(once "-a1))&1);%N")
rf8.c_define_with_body(body)
end
elseif as_shift_left = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
rf8.c_define_with_body(once "R=(C<<a1);")
end
elseif as_shift_right = name then
if type_bit.is_c_unsigned_ptr then
fe_long_bit(rf8)
else
rf8.c_define_with_body(once "R=(C>>a1);")
end
elseif as_last = name then
if type_bit.is_c_unsigned_ptr then
body.copy(once "{int ib=(CHAR_BIT*sizeof(int));%N%
%int widx=((")
type_bit.unsigned_padding.append_in(body)
body.extend('+')
; (type_bit.nb - 1).append_in(body)
body.append(once ")/ib);%N%
%unsigned int word=*(((unsigned int*)C)+widx);%N%
%int bidx=((")
; (type_bit.nb - 1).append_in(body)
body.extend('+')
type_bit.unsigned_padding.append_in(body)
body.append(once ")%%ib)+1;%N%
%int shift=ib-bidx;%N%
%R=(T6)((word>>shift)&1);%N}%N")
rf8.c_define_with_body(body)
elseif no_check then
body.copy(once "R=(T6)(((unsigned int)C)&1);%N")
rf8.c_define_with_body(body)
end
end
end
expanded_initializer(rt: E_TYPE): BOOLEAN is
do
if rt.is_user_expanded then
Result := rt.run_class.a_default_create /= Void
end
end
default_create is
do
end
is_integer(ct: E_TYPE): BOOLEAN is
local
tr: TYPE_REFERENCE
do
if ct.is_integer then
Result := True
else
tr ?= ct
if tr /= Void then
Result := tr.expanded_type.is_integer
end
end
end
integer_size(ct: E_TYPE): INTEGER_8 is
require
is_integer(ct)
local
type_integer: TYPE_INTEGER; type_reference: TYPE_REFERENCE
do
type_integer ?= ct
if type_integer = void then
type_reference ?= ct
type_integer ?= type_reference.expanded_type
end
Result := (type_integer.c_sizeof * 8).to_integer_8
ensure
(<<8, 16, 32, 64>>).fast_has(Result)
end
end -- NATIVE_SMART_EIFFEL
|