mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Compare commits
983 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f45836b59 | |||
| f5d3d89ac2 | |||
| ea3874ed3c | |||
| c43dd75ea9 | |||
| 810d13dacd | |||
| 6cc52b3210 | |||
| d759a73525 | |||
| bd6b48fa3b | |||
| d0ba7b95a9 | |||
| 5cce4ad433 | |||
| 874f828a7a | |||
| 1fc8e00e4a | |||
| 406159d412 | |||
| a9949f5da4 | |||
| d824488915 | |||
| 5ede25c40f | |||
| cee916ab0f | |||
| d90abc648e | |||
| 02e336ee27 | |||
| dd603d494d | |||
| 14e07f721a | |||
| b500e82950 | |||
| 9c36499e31 | |||
| 825241205f | |||
| 4a7309d327 | |||
| 0030417ace | |||
| 0dbb9e6e41 | |||
| 3d8a8fb661 | |||
| bb42c1b286 | |||
| d42d308620 | |||
| c858cba3e9 | |||
| 1c05764ba3 | |||
| 56842628b9 | |||
| 07d4498613 | |||
| d95ffb0362 | |||
| 1e009061f8 | |||
| 4063af90e2 | |||
| 2e33c2d120 | |||
| f5e10e294c | |||
| 69f9460075 | |||
| f0eb50a55d | |||
| 3104aed8c6 | |||
| 251fd74315 | |||
| d6a9ffa2b5 | |||
| bf56ecd2bf | |||
| 826e0b108f | |||
| 5e479c66d5 | |||
| 89cd742506 | |||
| 504788bf89 | |||
| dd07067067 | |||
| efa0314731 | |||
| d4101d0a08 | |||
| f3d5deb981 | |||
| 04d5e7da39 | |||
| 73418a90fa | |||
| 63b7439ddf | |||
| 34f82f24e9 | |||
| 2ddfd50df3 | |||
| 17ecf14511 | |||
| 165f79c877 | |||
| c68258f454 | |||
| d5ed73379f | |||
| da65d35d7a | |||
| 0903e2a72e | |||
| efef4541aa | |||
| 23e5c08e31 | |||
| 73ce5db170 | |||
| 05a8cc44cc | |||
| f20e10686c | |||
| cc59860e40 | |||
| 48b214f0b5 | |||
| baa1ee1faa | |||
| 8b590b5ec7 | |||
| 2cab36c289 | |||
| dc51d89ac2 | |||
| c5c156a6dd | |||
| 33deeae9eb | |||
| 6c5ccd5abe | |||
| 438d114917 | |||
| 56fdc449eb | |||
| 5e0f51c906 | |||
| 47a68e89ff | |||
| e91dfd07be | |||
| 0661ebb669 | |||
| dd81de49a6 | |||
| e4fc42ea11 | |||
| 04a4e59c83 | |||
| f4a3dc4f07 | |||
| 12ff88563d | |||
| c7452ff61f | |||
| b4817a54f0 | |||
| 126f0f0563 | |||
| 0fdf5d9bb9 | |||
| 0aa8db9a06 | |||
| 414a61a9d2 | |||
| 4bba769b95 | |||
| 28d5dabacd | |||
| a639a39883 | |||
| 0229446a30 | |||
| c7d96dbf84 | |||
| 9d950818ce | |||
| 8928bc2dce | |||
| bec4d30dc6 | |||
| e13f34e308 | |||
| b64ec814d6 | |||
| 1310368b3f | |||
| 02121cbd65 | |||
| a8b8d316ab | |||
| e1c9e7efab | |||
| 974e245ae0 | |||
| cdbcade041 | |||
| 0c96c4c34a | |||
| 01897f8456 | |||
| d531636584 | |||
| f8b938435c | |||
| 87ba84b048 | |||
| 66df8c619a | |||
| 672e016b13 | |||
| 9577e6ca6a | |||
| 48feda0692 | |||
| 123d15c5ab | |||
| 0290f06681 | |||
| 2ddd66cc4b | |||
| ffea200075 | |||
| a0662a16a3 | |||
| 90b53f4c29 | |||
| 3deb3a7aac | |||
| e66c6edaba | |||
| 80a7655b10 | |||
| dc5ade3729 | |||
| 596b542720 | |||
| 3fc848b545 | |||
| e8e28eacc7 | |||
| fe28e8617e | |||
| 9877f4ca3c | |||
| ced89c25ff | |||
| 16baea0677 | |||
| 58e9442737 | |||
| b210cfa34e | |||
| f80d5ece27 | |||
| 6f6eabf05a | |||
| f81591ceb6 | |||
| 62e5247300 | |||
| 92cc6b4996 | |||
| 12cc959998 | |||
| fb4767a3b7 | |||
| 892bf15cd7 | |||
| 69482dbc8e | |||
| 6587269af8 | |||
| a0c1e075e3 | |||
| 3a8d7bdf82 | |||
| 04561cd999 | |||
| dbe387a9d8 | |||
| f7ff4810f0 | |||
| 1cc1ade610 | |||
| 76241a9630 | |||
| 35c85cb21f | |||
| 0dfcaaed63 | |||
| a435cc94ec | |||
| d35cd42dc8 | |||
| ec6f46c05d | |||
| 7e116b5e8b | |||
| 5e752caf67 | |||
| d52c82d648 | |||
| e279528ff3 | |||
| b8486d73e2 | |||
| 676054c8df | |||
| 90283432a4 | |||
| 01aa2a990f | |||
| aecb3a33e6 | |||
| 0d76b90758 | |||
| 8e048ae25d | |||
| 74c9502bd4 | |||
| 1341e53961 | |||
| ca3a6156bf | |||
| 4585c360e4 | |||
| bb5c451dd4 | |||
| 7c9d9b1c89 | |||
| 0d22e11b75 | |||
| 5798c03de6 | |||
| f23918f61a | |||
| eb9d9e3425 | |||
| 8286e6052a | |||
| c52efe7be8 | |||
| 17cb50f8d0 | |||
| 757902c497 | |||
| 392aff7099 | |||
| d55367582c | |||
| b151a697e0 | |||
| c1f05a7fb3 | |||
| 4ac73307fd | |||
| 6323c995f3 | |||
| 15e7b3e8fe | |||
| 12cb7207ec | |||
| 1a9ac02d8d | |||
| 1099050377 | |||
| 4683a196d9 | |||
| 1fbabe207d | |||
| db2a7a1e6e | |||
| ae72feb468 | |||
| aabfe31d98 | |||
| 1fae7c0a69 | |||
| d44a1de8f4 | |||
| 49b01f23a4 | |||
| 9b501ab507 | |||
| 3a2ff9824e | |||
| 6d98ae57f2 | |||
| 14a92f9705 | |||
| d57d6e2b5b | |||
| 6312a50045 | |||
| 6491d8dd28 | |||
| 54bfcaf1ff | |||
| 38de04c4f7 | |||
| dad43359cb | |||
| 88a11d81b0 | |||
| 825c14a0c5 | |||
| 2850b58dd9 | |||
| 3419426dbf | |||
| 4e90d6938a | |||
| 7f73af079a | |||
| 3bfafd198c | |||
| 0bb4afe942 | |||
| e96620cd23 | |||
| 8b2fd45d46 | |||
| 6c1c2041ef | |||
| 16cb81c727 | |||
| 788ee38bdf | |||
| 366780f0bc | |||
| 3069299200 | |||
| 01a6cdb882 | |||
| a65c33c487 | |||
| 5337e9375c | |||
| 74e1d1ea02 | |||
| 68af0cca65 | |||
| a528312542 | |||
| c17f1be52a | |||
| bc90635e83 | |||
| 2a42cc2d69 | |||
| 8f06789cb3 | |||
| fcc9b7fc2a | |||
| 97eed4493f | |||
| 340f1f0094 | |||
| 6f6149509a | |||
| 563ebbf083 | |||
| f7c5c00d6e | |||
| 36376eba5f | |||
| db1b78820d | |||
| 08d4365252 | |||
| d21d5993b9 | |||
| fbe5033f80 | |||
| 8f8e832767 | |||
| d432688d9f | |||
| 1b7197622f | |||
| 0396f3f0fd | |||
| aa6fc8c38e | |||
| c1c8c25e70 | |||
| aec8eba076 | |||
| 2f177dcd72 | |||
| c6364edd96 | |||
| 4fa3359d44 | |||
| d5cb54d4df | |||
| e9fe337b95 | |||
| 940dec5e7d | |||
| 456878ba06 | |||
| 116e128b1a | |||
| 092dd4a667 | |||
| 2e9b8f0d9b | |||
| ed29d74bfd | |||
| 8b52c67be9 | |||
| de03e97a50 | |||
| 9e41ae4909 | |||
| 9cffacdf0d | |||
| 1b6efeef57 | |||
| 07668b067b | |||
| f84668f8d5 | |||
| 58ef897696 | |||
| 6e5a0f623f | |||
| 63d82142a8 | |||
| 73b4152574 | |||
| 00d1fd0e6f | |||
| 3972df57fe | |||
| 4cd3493737 | |||
| 4452041ebb | |||
| f6ad163841 | |||
| e1fa01b9c8 | |||
| 42f33fd51a | |||
| 00df809609 | |||
| 661081a072 | |||
| 504b731af6 | |||
| affb18b85b | |||
| 826fe1bc36 | |||
| dd0715fd58 | |||
| 25985876b8 | |||
| 9ba0ebec0e | |||
| a7d84382f8 | |||
| 5c205e6ea1 | |||
| 98d5aa8d74 | |||
| 1c361f8a22 | |||
| d56db2296d | |||
| 3bc9453c9a | |||
| a56b601f56 | |||
| 0ecb0fd97b | |||
| 9f5c0777f1 | |||
| 82f3e4d31b | |||
| d4439479cf | |||
| df13d418c3 | |||
| c6071335a1 | |||
| b0cea30f32 | |||
| 8da2c11243 | |||
| 6d07d9b3d7 | |||
| cb7eb202ce | |||
| 6059834244 | |||
| fdce0e712b | |||
| 13fc503434 | |||
| 0cb3a7186c | |||
| 521c16d738 | |||
| 7f5e257f77 | |||
| e0b8876640 | |||
| 58ba883ee9 | |||
| 79af3f30b4 | |||
| 3c63d38058 | |||
| 63d4e8eca2 | |||
| 7150c67539 | |||
| 6dedd6a940 | |||
| 66f2e733e5 | |||
| a33f9d7b65 | |||
| 50b57f6ff1 | |||
| 2daf1987f9 | |||
| 71f9add1c5 | |||
| fba7874a68 | |||
| 6e17122c6d | |||
| 038bad2f41 | |||
| 6a284872ce | |||
| a7b50be35b | |||
| fc98aa290f | |||
| 40235f3050 | |||
| 2e30c68562 | |||
| 4d21a68d35 | |||
| 9e114fc913 | |||
| e55abd2390 | |||
| db00fb238b | |||
| 36e3c4404a | |||
| 67f3626b5c | |||
| 4803c872e2 | |||
| e4e4eeb0c3 | |||
| 3a92a4e3d8 | |||
| 6f53e2c059 | |||
| c6c0b796e1 | |||
| b1ee892818 | |||
| e6b06eafb3 | |||
| 2f85290065 | |||
| 0d8b1eaee5 | |||
| 2b0f908017 | |||
| 01dc2265ff | |||
| 39a11f323e | |||
| abdd006df3 | |||
| 2d9bf22730 | |||
| 17532874a8 | |||
| a67b88e223 | |||
| 2a97e97db4 | |||
| 76b036a627 | |||
| ac2dfa8c47 | |||
| 1c7a1926a3 | |||
| fd3576e888 | |||
| 1cd8b4c933 | |||
| 1864816d1e | |||
| e02d0ff78c | |||
| 049e749c8b | |||
| b2bfcabae2 | |||
| 3d056d084a | |||
| 544784effd | |||
| a045b6b8d9 | |||
| e3b91b8d41 | |||
| a3685c4c04 | |||
| a3221bf8cd | |||
| 3179944e81 | |||
| 66d044ec3e | |||
| 734f6b1cc4 | |||
| 55e1275778 | |||
| c6c18c32b0 | |||
| 00751ccbcd | |||
| 59e581ed78 | |||
| a7bcbd8bdc | |||
| 33f1970df2 | |||
| 07053e5654 | |||
| 3ac6c3f090 | |||
| 7f9b4e056d | |||
| 551bf0c635 | |||
| 1e340cf869 | |||
| eb52c29b2d | |||
| 8258b7b5b3 | |||
| 1974aa0f72 | |||
| 5f7eb20256 | |||
| 98d0f1b98e | |||
| fb028b47aa | |||
| 1088feb110 | |||
| ebf380474c | |||
| 749ac0a021 | |||
| aaa12911e2 | |||
| 56a60fa7b7 | |||
| 5dc9a8249f | |||
| fd113da3aa | |||
| 15d6e172e9 | |||
| f50cde9924 | |||
| 25e76ee5ce | |||
| a211a326de | |||
| e7d0baaf3b | |||
| b9c80a5357 | |||
| d3e17eedee | |||
| e0df303547 | |||
| 557e0645bf | |||
| 26dd35be59 | |||
| dbb6010d8e | |||
| eca6266524 | |||
| 4cea788970 | |||
| 3d8350f920 | |||
| 7c80edb577 | |||
| 5abb283dd7 | |||
| 1f12525154 | |||
| bed04414d7 | |||
| 68cebb6331 | |||
| a8cd364ece | |||
| 9fbf0ef886 | |||
| aae8237335 | |||
| 354934d398 | |||
| 37a1884749 | |||
| 3107d1caae | |||
| 3bb419aeab | |||
| 2609f0a2b3 | |||
| 5156ea997f | |||
| 7c470e25b8 | |||
| cbc3dbedb4 | |||
| 8a019106c0 | |||
| 8a6614d30e | |||
| 144cf6cd58 | |||
| e334c02a50 | |||
| acc114003b | |||
| a6119b0077 | |||
| bb1fb2f43d | |||
| 2c6a5d3a77 | |||
| 10c1c9d6f8 | |||
| 8a5dfa92ab | |||
| dd3ed8d99c | |||
| 19450df41e | |||
| 600e3330b3 | |||
| 4dcd8dd7ce | |||
| e941fb7866 | |||
| 8398020d0a | |||
| 69dbe8cfa5 | |||
| 08df172e91 | |||
| 06a8e502fa | |||
| fdbb1731ce | |||
| 5edac8b885 | |||
| 368f8a5da6 | |||
| 0c55b85fb0 | |||
| 7fb62670a9 | |||
| 292a096118 | |||
| 75beb55c2a | |||
| f8ce3bec13 | |||
| bad6223914 | |||
| ac4eb99629 | |||
| af13cfb7d5 | |||
| 89f591485b | |||
| 280cb80a0d | |||
| ff2ef44c0e | |||
| 6a5e97b448 | |||
| cc20c5ca3a | |||
| a00eabbf5d | |||
| f2d8db39be | |||
| 352c4755b2 | |||
| 0df460892c | |||
| 82249bb973 | |||
| 0cba422488 | |||
| 9288805435 | |||
| e993b83c50 | |||
| 926ec1dc7e | |||
| e2829bef0d | |||
| 06d231d372 | |||
| 8455344bf3 | |||
| 2a52ebcc56 | |||
| d93fc6593f | |||
| f77113e841 | |||
| d9bd77b180 | |||
| 4e535080dc | |||
| afba74ff50 | |||
| aa4d8e9a2b | |||
| 0113db6716 | |||
| b77a0f69a3 | |||
| 5d85045fcb | |||
| d13df1536d | |||
| f8156ae175 | |||
| b08da9c30b | |||
| 963b44286a | |||
| 82a2a5657c | |||
| ea5d0a593c | |||
| b7e8406f6c | |||
| 0be5b266b6 | |||
| ac51a58683 | |||
| 436765eb94 | |||
| ddfac9aba0 | |||
| 9233d28ac7 | |||
| dc886873bc | |||
| 70ee936367 | |||
| c427776910 | |||
| 9a5c78dc26 | |||
| 331b119313 | |||
| b5e4e283e8 | |||
| f000856d68 | |||
| 943029954f | |||
| bc9566eb64 | |||
| 6cc29ed377 | |||
| e4d4192c3a | |||
| a5d05ea8b7 | |||
| 86981dafb1 | |||
| 5dff2194a2 | |||
| 78f7162508 | |||
| ccca5e521c | |||
| 212800a901 | |||
| 353ecd7119 | |||
| 0736d7c99f | |||
| 385cebe0b9 | |||
| 3847c7eb64 | |||
| 24ffa4386a | |||
| 33742d941f | |||
| c1ad4c4261 | |||
| 41d5df03ed | |||
| 32ffd81011 | |||
| cb636215bb | |||
| d35677f213 | |||
| 76eafa4608 | |||
| 78d185efb9 | |||
| f24658816c | |||
| 43863d5f01 | |||
| 336f0de8bb | |||
| 07224f8ed9 | |||
| 69a6bb1f12 | |||
| 17247c51f2 | |||
| fd38b9217d | |||
| edc49f9d26 | |||
| f0a64329b1 | |||
| 81c2108819 | |||
| 27492e53a0 | |||
| 8d36393a5b | |||
| 3c55cb0895 | |||
| a373c48f3b | |||
| c9db7d3531 | |||
| 045761390d | |||
| 0589749952 | |||
| 4b5dd5683b | |||
| 6b457d2c00 | |||
| c779413df3 | |||
| 9cebddf9fe | |||
| 21e07d6113 | |||
| 5b40bb8d15 | |||
| bec4d05340 | |||
| 8c276f95be | |||
| 82046ff26e | |||
| 3d6adccfbe | |||
| 5069fb15e4 | |||
| 7ca59ecea2 | |||
| 041351fb05 | |||
| 34356974ee | |||
| d2b548de60 | |||
| c80ece2149 | |||
| 356b719fef | |||
| 896338e219 | |||
| bff79112a6 | |||
| f1d02bfc15 | |||
| c1f5fdafb6 | |||
| 5d1d94d911 | |||
| 762556b6e8 | |||
| 618c589162 | |||
| ab2b42d363 | |||
| b9007244bd | |||
| 7932523052 | |||
| 12881ccb05 | |||
| 3ff2757bf7 | |||
| 4dcc1819c9 | |||
| 21ee56d82a | |||
| 55a2ff5faf | |||
| ed97c1779e | |||
| 0d8793047d | |||
| cbb46f6975 | |||
| 0c242e278d | |||
| 932b93fd12 | |||
| a4c5824e59 | |||
| afcf19b727 | |||
| 30424dfa74 | |||
| 9b8e5658ce | |||
| a127ded486 | |||
| fe3c3bb661 | |||
| f9e781d83a | |||
| fc8885f2f4 | |||
| fe1ad37bfb | |||
| 9e842b3a75 | |||
| b81edb0035 | |||
| 86dee45f1d | |||
| 08f61db6ee | |||
| 7f66e50ba2 | |||
| 5592c7413a | |||
| fff0f17b49 | |||
| 2b05cf48d0 | |||
| dae0de4461 | |||
| cfe8b0c81d | |||
| 026726dd49 | |||
| d7986b449d | |||
| 4970e24a1c | |||
| 950e60363a | |||
| 87c7064bad | |||
| 4cf1da9542 | |||
| b01207ea94 | |||
| c2444b8424 | |||
| 8461be11fc | |||
| 260db0f5fb | |||
| 99ef00fe02 | |||
| b9dfd0438f | |||
| d0b5d720ac | |||
| dd1ce5d53e | |||
| 7eaaee5405 | |||
| 471479e723 | |||
| 397b005715 | |||
| bf118b9006 | |||
| 7e3d22f095 | |||
| 01dbbcd553 | |||
| e479a42757 | |||
| 5134031e18 | |||
| befcbd5607 | |||
| 9d613159b5 | |||
| 3e71359d7a | |||
| 2b188ed8a1 | |||
| 59af217779 | |||
| 2bb84f1f1a | |||
| 850e200e84 | |||
| b978231bda | |||
| b7fe929232 | |||
| 20ffc2206a | |||
| caee1f68a2 | |||
| a4302524d0 | |||
| 12d31c33af | |||
| 5a7cbebc8a | |||
| 04fd7af23c | |||
| 2a92fb2516 | |||
| 18e3d39ee2 | |||
| 55163a8a0a | |||
| 867268897a | |||
| 11317de468 | |||
| 857a1d9fc9 | |||
| b44326b561 | |||
| 8bd1bc47b3 | |||
| c45674aff0 | |||
| 80fe9838d2 | |||
| 40d0d8fe0e | |||
| ee544dc881 | |||
| ed32b6fcdc | |||
| c8cf9512cd | |||
| 1835753f9f | |||
| 424afa4446 | |||
| 02e69d1c2c | |||
| 44a07393f4 | |||
| 0b22bf4a89 | |||
| 1520c97e17 | |||
| 8a87549315 | |||
| ef9df5dc7d | |||
| 7dc595f98f | |||
| d4b89ccc61 | |||
| 72d071540c | |||
| dea185e687 | |||
| 968053a35b | |||
| 66114f8332 | |||
| 8813ebec07 | |||
| a93ef815be | |||
| 905d4010bf | |||
| 763b39d00b | |||
| 107c777341 | |||
| 500f721f70 | |||
| cb89e1f0d9 | |||
| 6bc5857125 | |||
| bfb7b491cc | |||
| c1f112c49a | |||
| 0d7b4deccf | |||
| f467b02d45 | |||
| a54a3df32c | |||
| 3ad6bbc40c | |||
| 67d92c48b5 | |||
| 6fbc03b3a8 | |||
| 690cafe274 | |||
| 4e56e0defc | |||
| 53e46be7e2 | |||
| 73e289c54e | |||
| ce372122ed | |||
| a733c6e0ea | |||
| 425b142168 | |||
| f751c28ca4 | |||
| 4281429412 | |||
| 0e50ea90f3 | |||
| 1eb71b008f | |||
| 84a68ca5ae | |||
| 5e9dc72bc5 | |||
| 1eacdae319 | |||
| 59b35250cc | |||
| 2b45d454bc | |||
| ff0e3bcea6 | |||
| 8b3f3c0bf3 | |||
| cf2aabdad6 | |||
| 3d8a38bea4 | |||
| 639946a006 | |||
| fb5e8ab6d5 | |||
| 11955ca1a1 | |||
| 52dd0a8cd7 | |||
| 6db0162ec7 | |||
| dec34d6c7b | |||
| 8f0ac27196 | |||
| fd10c72319 | |||
| ce7508e0d5 | |||
| c29212cf44 | |||
| 6e86e290e4 | |||
| b2398879fa | |||
| e01648b86b | |||
| e0c9b53217 | |||
| ce30a4e04b | |||
| 31877043c4 | |||
| 167a747a41 | |||
| cfc958b01a | |||
| 015f06ed8e | |||
| 95169097fc | |||
| 474545bba2 | |||
| 925cd2ab8f | |||
| 9debf63340 | |||
| 0f978932e2 | |||
| 6488ae855f | |||
| d2f267a13d | |||
| a4a1e01e81 | |||
| ee111dd175 | |||
| f0c1126997 | |||
| b7031e8bc8 | |||
| 52507b1083 | |||
| 7deb41b0e8 | |||
| f1c06eef7c | |||
| 449317a251 | |||
| d428fa0c4a | |||
| daa37be549 | |||
| ad15e59cd9 | |||
| 71eb4b2b22 | |||
| d93b1a48d2 | |||
| 3a64cde61d | |||
| 4684864f04 | |||
| dd8c178a73 | |||
| 029c7c1116 | |||
| a68f005fd7 | |||
| 1adf93aa54 | |||
| 26da07db15 | |||
| 7ab7cadbbb | |||
| 2c1d209fd5 | |||
| 5a3e014e49 | |||
| 744ba80919 | |||
| 0d755e583c | |||
| 92d8012b4e | |||
| cc587e6535 | |||
| 1122124f97 | |||
| 5405977a6e | |||
| f6dcc6dcfc | |||
| 9712379e0f | |||
| b67955b8ca | |||
| 2a366ffba8 | |||
| 8864c30d16 | |||
| 3516a3c012 | |||
| fa6a9f6f13 | |||
| 00f5ddc9ae | |||
| dcd3e5907c | |||
| 80c15ddd15 | |||
| 7fde48b838 | |||
| 509f2bfd93 | |||
| b941e91866 | |||
| 312f54b580 | |||
| 3a162cc33f | |||
| b60809f117 | |||
| 0881e34496 | |||
| 24ad5f35b1 | |||
| 3c222e4e71 | |||
| e2063fc267 | |||
| 68f8d73308 | |||
| 246c76e261 | |||
| 6128ae61a8 | |||
| e3e5596960 | |||
| 1bcf6d9f3c | |||
| 97e3c3a5a3 | |||
| acd5317fb1 | |||
| 8d90c7c0fa | |||
| 5a88904fe8 | |||
| b3db34c2a8 | |||
| 6b7c12f523 | |||
| fa18ffa90c | |||
| 3ec61c0929 | |||
| 10b1a52bb8 | |||
| dcfc2dbf14 | |||
| d70536e0e8 | |||
| fdbfeaf533 | |||
| ea31878b1f | |||
| d33b9dc81f | |||
| d612344e48 | |||
| d7e183bfdf | |||
| d5c010422a | |||
| 5738ed0474 | |||
| 3174061593 | |||
| 76d752c03b | |||
| 33647b904e | |||
| 47f65a93c5 | |||
| a2fbb98fa6 | |||
| 721f934b9b | |||
| d2cab16301 | |||
| eddd324979 | |||
| f221f4e0fa | |||
| a476d71143 | |||
| 1e156974d5 | |||
| 8853b03591 | |||
| f53781bdeb | |||
| afc0d7a6c3 | |||
| c4f75c7de0 | |||
| 9ea7b71868 | |||
| 57611240a9 | |||
| a97f085c52 | |||
| 2bf9fd06d2 | |||
| dffe4bc8ba | |||
| 4375bffee5 | |||
| e440681a06 | |||
| 758f8f4baf | |||
| ea3b02e387 | |||
| 069d9bb4d7 | |||
| 9757616c57 | |||
| e8723a4f3f | |||
| 5bfb70e9db | |||
| 8b65e4b73c | |||
| 4e15832000 | |||
| c27e451931 | |||
| c345fe4321 | |||
| f99c315400 | |||
| e2c628583e | |||
| 705f95c983 | |||
| 6b8664b951 | |||
| f08f3c34be | |||
| 510b9e7abc | |||
| 564372d7b9 | |||
| a66d86cfc1 | |||
| 96bae1d508 | |||
| 77c35e7097 | |||
| 2aa70e9690 | |||
| ae09a219d5 | |||
| c5dc184a6d | |||
| bab7e9f032 | |||
| 3b8df2c285 | |||
| cfaaf7c6d4 | |||
| 5210482c59 | |||
| 5e55b61c44 | |||
| 4695dfdcb6 | |||
| 55482063a7 | |||
| ab5726d4e4 | |||
| 0d54568b4d | |||
| df969b163a | |||
| ad8b36daa1 | |||
| c849b894ed | |||
| d8e060d2d3 | |||
| 9742bce198 | |||
| 7f8d38bbbe | |||
| 0b95c8a1e8 | |||
| 57a798e687 | |||
| 755233ef7d | |||
| 8f99689ba3 | |||
| 11cc7bed96 | |||
| ef9c68795f | |||
| fde95a7db5 | |||
| cfb799a18e | |||
| 43443d9377 | |||
| faed5054f8 | |||
| 0a505dcfd6 | |||
| 1517d77e93 | |||
| 9571a4c07e | |||
| d96be5c1b2 | |||
| 0983c723c5 | |||
| 425b5f32d6 | |||
| 0c88c71786 | |||
| f868d7d357 | |||
| c69ca2c7f8 | |||
| ccd5f203bf | |||
| 5c2b11d215 | |||
| c9ba761b9e | |||
| 2b588b8566 | |||
| b4f4f5968b | |||
| e7599050dc | |||
| 0e9bd24827 | |||
| b920270508 | |||
| 491aa1bfe5 | |||
| c99bb756c4 | |||
| 097f525817 | |||
| 5533c29833 | |||
| 0bb4d10ca7 | |||
| 914da3d712 | |||
| 670622f45d | |||
| 97f71b5a67 | |||
| 639703cf01 | |||
| 6334949ba6 | |||
| b1847721e8 | |||
| f0afdf7496 | |||
| 0685784119 | |||
| 5f4a27217e | |||
| c9ea39843b | |||
| a6f31ad6ce | |||
| 07b75d927e | |||
| 71254be076 | |||
| 1d2c5c12d3 | |||
| 00337543a5 | |||
| f76defd310 | |||
| d023adcb12 | |||
| 5b2763821e | |||
| 6d073f8d99 | |||
| 667ace2bfe | |||
| ffe8bf6323 | |||
| a79d1ba9ff | |||
| fe1ec9afdd | |||
| 1952004d5a | |||
| e41f1f5139 | |||
| 495c1a377a | |||
| 9f52bcfca9 | |||
| a2b8c08a52 | |||
| f00657ead7 | |||
| 2e56da5a78 | |||
| 60279b2a8e | |||
| c6b8b58e0e | |||
| 7f66cf7d66 | |||
| 9840d6a2e7 | |||
| b5bf9510ee | |||
| 5dc87f77d4 | |||
| f74d370c15 | |||
| 38b0759108 | |||
| 4d32c671a7 | |||
| bfd58a3fb3 | |||
| 1a4089803d | |||
| 4bf050a192 | |||
| 49896a4d28 | |||
| 0e5394638b | |||
| ad44021591 | |||
| 5759256ff8 | |||
| 5184263bdc | |||
| 6f945a09b4 | |||
| e7bd7d0eaf | |||
| 41e3220539 | |||
| e3bb95bb6d | |||
| 5df95e8d7b | |||
| 99bb2154ff | |||
| 28e39419a5 | |||
| 042f98912f | |||
| bb23faae65 | |||
| 308c6c8311 | |||
| 37d6628688 | |||
| 338c8538c9 | |||
| c5fd8cbbe1 | |||
| 8a44903992 | |||
| 3a79d60515 | |||
| 01a8d8498f | |||
| b759746890 | |||
| b3dace6ae3 | |||
| 4d393d5d09 | |||
| 5c7adf0534 | |||
| 4f189b2be9 | |||
| 81fc5ff48a | |||
| 5746958470 | |||
| 97319697c8 | |||
| 612e5d6aad | |||
| ba9f81db8b | |||
| 5b9f7c0b93 | |||
| ce167d70b7 | |||
| 0ed623c442 | |||
| 206f7ce272 | |||
| b59283a03f | |||
| 3cf48713a2 | |||
| 6d5652114e | |||
| b1017b2651 | |||
| b8d896e56a | |||
| db296e9593 | |||
| 9840e5352b | |||
| 0aa5aa1de2 | |||
| 25d9370f97 | |||
| 2bab6e197d | |||
| 893cc2780c |
+119
-76
@@ -3,104 +3,147 @@ name: Build & Test
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Ubuntu-1604:
|
Check-Skip:
|
||||||
runs-on: ubuntu-16.04
|
if: |
|
||||||
|
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip gha]')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- run: echo not skip
|
||||||
- name: apt
|
|
||||||
run: sudo apt install ruby gperf
|
Ubuntu-1604:
|
||||||
- name: build and test
|
needs: Check-Skip
|
||||||
run: rake -m -j4 all test
|
runs-on: ubuntu-16.04
|
||||||
env:
|
env:
|
||||||
MRUBY_CONFIG: travis_config.rb
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: gcc
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Ruby version
|
||||||
|
run: ruby -v
|
||||||
|
- name: Compiler version
|
||||||
|
run: ${{ env.CC }} --version
|
||||||
|
- name: Build and test
|
||||||
|
run: rake -m test:build && rake test:run
|
||||||
|
|
||||||
Ubuntu-1804-gcc:
|
Ubuntu-1804-gcc:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
env:
|
||||||
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: gcc
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: apt
|
- name: Ruby version
|
||||||
run: sudo apt install ruby gperf gcc g++
|
run: ruby -v
|
||||||
- name: build and test
|
- name: Compiler version
|
||||||
run: rake -m -j4 all test
|
run: ${{ env.CC }} --version
|
||||||
env:
|
- name: Build and test
|
||||||
MRUBY_CONFIG: travis_config.rb
|
run: rake -m test:build && rake test:run
|
||||||
CC: gcc
|
|
||||||
CXX: g++
|
|
||||||
|
|
||||||
Ubuntu-1804-clang:
|
Ubuntu-1804-clang:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
env:
|
||||||
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: clang
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: apt
|
- name: Ruby version
|
||||||
run: sudo apt install ruby gperf
|
run: ruby -v
|
||||||
- name: build and test
|
- name: Compiler version
|
||||||
run: rake -m -j4 all test
|
run: ${{ env.CC }} --version
|
||||||
env:
|
- name: Build and test
|
||||||
MRUBY_CONFIG: travis_config.rb
|
run: rake -m test:build && rake test:run
|
||||||
CC: clang
|
|
||||||
CXX: clang++
|
|
||||||
|
|
||||||
macOS:
|
macOS:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
env:
|
||||||
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: clang
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: brew
|
- name: Ruby version
|
||||||
run: brew install ruby gperf
|
run: ruby -v
|
||||||
- name: build and test
|
- name: Compiler version
|
||||||
run: rake -m -j4 all test
|
run: ${{ env.CC }} --version
|
||||||
env:
|
- name: Build and test
|
||||||
MRUBY_CONFIG: travis_config.rb
|
run: rake -m test:build && rake test:run
|
||||||
|
|
||||||
Windows-MinGW:
|
Windows-MinGW:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: gcc
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: chocolatey
|
- name: Ruby version
|
||||||
run: choco install -y ruby gperf
|
run: ruby -v
|
||||||
- name: build and test
|
- name: Compiler version
|
||||||
run: rake -E '$stdout.sync=true' -j4 test
|
run: ${{ env.CC }} --version
|
||||||
env:
|
- name: Build and test
|
||||||
MRUBY_CONFIG: travis_config.rb
|
run: rake -m test:build && rake test:run
|
||||||
CFLAGS: -g -O1 -Wall -Wundef
|
|
||||||
|
|
||||||
Windows-Cygwin:
|
Windows-Cygwin:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
||||||
|
MRUBY_CONFIG: ci/gcc-clang
|
||||||
|
CC: gcc
|
||||||
|
installer-path: '%TMP%\cygwin-setup.exe'
|
||||||
|
cygwin-root: C:\cygwin
|
||||||
|
package-dir: C:\cygwin-package
|
||||||
|
cache-version: v1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
|
path: ${{ env.package-dir }}
|
||||||
key: ${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-${{ github.sha }}
|
key: ${{ runner.os }}-cygwin-${{ env.cache-version }}
|
||||||
restore-keys: |
|
- name: Download Cygwin installer
|
||||||
${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-
|
shell: cmd
|
||||||
${{ runner.os }}-cygwin-chocolatey-
|
run: >
|
||||||
- name: chocolatey
|
bitsadmin /transfer download /priority foreground
|
||||||
run: choco install -y cygwin
|
https://cygwin.com/setup-x86_64.exe ${{ env.installer-path }}
|
||||||
- name: Install cygwin packages
|
- name: Install Cygwin
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: C:\tools\cygwin\cygwinsetup.exe -qgnNdO -R C:/tools/cygwin -l C:/tools/cygwin/package -s http://mirrors.kernel.org/sourceware/cygwin/ -P gcc-core,gcc-g++,make,gperf,ruby
|
run: >
|
||||||
- name: Set ENV
|
${{ env.installer-path }}
|
||||||
run: |
|
--quiet-mode --no-shortcuts --no-startmenu --no-desktop --no-admin
|
||||||
echo '::set-env name=PATH::C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin'
|
--only-site --site http://mirrors.kernel.org/sourceware/cygwin/
|
||||||
- name: build and test
|
--root ${{ env.cygwin-root }}
|
||||||
shell: cmd
|
--local-package-dir ${{ env.package-dir }}
|
||||||
run: C:\tools\cygwin\bin\ruby.exe /usr/bin/rake -m -j4 -E 'STDOUT.sync=true' test
|
--packages gcc-core,gcc-g++,ruby
|
||||||
env:
|
- name: Set PATH for Cygwin
|
||||||
MRUBY_CONFIG: travis_config.rb
|
run: |
|
||||||
|
echo '::set-env name=PATH::${{ env.cygwin-root }}\bin;${{ env.cygwin-root }}\usr\bin'
|
||||||
|
- name: Ruby version
|
||||||
|
shell: cmd
|
||||||
|
run: ruby -v
|
||||||
|
- name: Compiler version
|
||||||
|
run: ${{ env.CC }} --version
|
||||||
|
- name: Build and test
|
||||||
|
shell: cmd
|
||||||
|
run: ruby /usr/bin/rake -m test:build && ruby /usr/bin/rake test:run
|
||||||
|
- name: Set PATH for cache archiving (tar)
|
||||||
|
# set Windows path so that Cygwin tar is not used for cache archiving
|
||||||
|
run: echo '::set-env name=PATH::C:\windows\System32'
|
||||||
|
|
||||||
Windows-VC:
|
Windows-VC:
|
||||||
|
needs: Check-Skip
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
MRUBY_CONFIG: ci/msvc
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: chocolatey
|
- name: Ruby version
|
||||||
run: choco install -y ruby gperf
|
run: ruby -v
|
||||||
- name: build and test
|
- name: Build and test
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
rake -E "STDOUT.sync=true" -m -j4 test
|
rake -m test:build && rake test:run
|
||||||
env:
|
|
||||||
MRUBY_CONFIG: appveyor_config.rb
|
|
||||||
# TODO(take-cheeze): Re-enable /O2
|
|
||||||
CFLAGS: "/c /nologo /W3 /we4013 /Zi /MD /D_CRT_SECURE_NO_WARNINGS"
|
|
||||||
CXXFLAGS: "/c /nologo /W3 /Zi /MD /EHs /D_CRT_SECURE_NO_WARNINGS"
|
|
||||||
|
|||||||
@@ -8,44 +8,48 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL-Build:
|
CodeQL-Build:
|
||||||
|
if: |
|
||||||
|
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip gha]')
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
# We must fetch at least the immediate parents so that if this is
|
# We must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head.
|
# a pull request then we can checkout the head.
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
# If this run was triggered by a pull request event, then checkout
|
# If this run was triggered by a pull request event, then checkout
|
||||||
# the head of the pull request instead of the merge commit.
|
# the head of the pull request instead of the merge commit.
|
||||||
- run: git checkout HEAD^2
|
- run: git checkout HEAD^2
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v1
|
|
||||||
# Override language selection by uncommenting this and choosing your languages
|
|
||||||
# with:
|
|
||||||
# languages: go, javascript, csharp, python, cpp, java
|
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Initializes the CodeQL tools for scanning.
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
- name: Initialize CodeQL
|
||||||
- name: Autobuild
|
uses: github/codeql-action/init@v1
|
||||||
uses: github/codeql-action/autobuild@v1
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
|
# with:
|
||||||
|
# languages: go, javascript, csharp, python, cpp, java
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# 📚 https://git.io/JvXDl
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# and modify them (or add more) to build your code if your project
|
# 📚 https://git.io/JvXDl
|
||||||
# uses a compiled language
|
|
||||||
|
|
||||||
#- run: |
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
# make bootstrap
|
# and modify them (or add more) to build your code if your project
|
||||||
# make release
|
# uses a compiled language
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
# - run: |
|
||||||
uses: github/codeql-action/analyze@v1
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: ❄️ Lint
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
yamllint:
|
||||||
|
name: 🍶 YAML
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: 🧹 YAML Lint
|
||||||
|
uses: ibiqlik/action-yamllint@v3
|
||||||
|
markdownlint:
|
||||||
|
name: 🍸 Markdown
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: 🚀 Use Node.js
|
||||||
|
uses: actions/setup-node@v2.1.4
|
||||||
|
with:
|
||||||
|
node-version: '12.x'
|
||||||
|
- run: npm install -g markdownlint-cli@0.25.0
|
||||||
|
- run: markdownlint '**/*.md'
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
name: CIFuzz
|
|
||||||
on: [pull_request]
|
|
||||||
jobs:
|
|
||||||
Fuzzing:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Build Fuzzers
|
|
||||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
|
||||||
with:
|
|
||||||
oss-fuzz-project-name: 'mruby'
|
|
||||||
dry-run: false
|
|
||||||
- name: Run Fuzzers
|
|
||||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
|
||||||
with:
|
|
||||||
oss-fuzz-project-name: 'mruby'
|
|
||||||
fuzz-seconds: 600
|
|
||||||
dry-run: false
|
|
||||||
- name: Upload Crash
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
name: artifacts
|
|
||||||
path: ./out/artifacts
|
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
name: CIFuzz
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
Fuzzing:
|
||||||
|
if: |
|
||||||
|
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip gha]')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Build Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'mruby'
|
||||||
|
dry-run: false
|
||||||
|
- name: Run Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'mruby'
|
||||||
|
fuzz-seconds: 600
|
||||||
|
dry-run: false
|
||||||
|
- name: Upload Crash
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out/artifacts
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: 💎 Spellchecker
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
misspell:
|
||||||
|
name: 🧹 Check Spelling
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🍒 Check Out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: 🍅 Install
|
||||||
|
run: |
|
||||||
|
wget -O - -q https://git.io/misspell | sh -s -- -b .
|
||||||
|
- name: 🌶️ Misspell
|
||||||
|
run: |
|
||||||
|
git ls-files --empty-directory | xargs ./misspell -error
|
||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
stages:
|
stages:
|
||||||
- pretest
|
- pretest
|
||||||
- test
|
- test
|
||||||
pretest:
|
pretest:
|
||||||
stage: pretest
|
stage: pretest
|
||||||
image: registry.gitlab.com/dabroz/mruby:gcc47_0.1
|
image: registry.gitlab.com/dabroz/mruby:gcc47_0.1
|
||||||
tags:
|
tags:
|
||||||
- linux
|
- linux
|
||||||
variables:
|
variables:
|
||||||
CC: gcc-4.7
|
CC: gcc-4.7
|
||||||
CXX: g++-4.7
|
CXX: g++-4.7
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
MD001: false
|
||||||
|
MD003: false
|
||||||
|
MD004: false
|
||||||
|
MD005: false
|
||||||
|
MD007: false
|
||||||
|
MD010: false
|
||||||
|
MD011: false
|
||||||
|
MD013: false
|
||||||
|
MD014: false
|
||||||
|
MD024: false
|
||||||
|
MD025: false
|
||||||
|
MD026: false
|
||||||
|
MD034: false
|
||||||
|
MD040: false
|
||||||
|
MD041: false
|
||||||
|
MD046: false
|
||||||
+2
-2
@@ -5,7 +5,7 @@ jobs:
|
|||||||
- os: osx
|
- os: osx
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- MRUBY_CONFIG=travis_config.rb
|
- MRUBY_CONFIG=ci/gcc-clang
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- rake -m && rake test
|
- rake -m test:build && rake test:run
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
document-start: disable
|
||||||
|
line-length: disable
|
||||||
|
truthy: false
|
||||||
@@ -43,3 +43,6 @@ of this list.
|
|||||||
YAMAMOTO Masaya
|
YAMAMOTO Masaya
|
||||||
KOBAYASHI Shuji
|
KOBAYASHI Shuji
|
||||||
RIZAL Reckordp
|
RIZAL Reckordp
|
||||||
|
Rory O'Connell
|
||||||
|
John Bampton
|
||||||
|
Seeker
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
* @matz
|
||||||
+6
-13
@@ -1,6 +1,7 @@
|
|||||||
# How to contribute
|
# How to contribute
|
||||||
|
|
||||||
mruby is an open-source project which is looking forward to each contribution.
|
mruby is an open-source project which is looking forward to each contribution.
|
||||||
|
Contributors agree to license their contribution(s) under MIT license.
|
||||||
|
|
||||||
## Your Pull Request
|
## Your Pull Request
|
||||||
|
|
||||||
@@ -33,11 +34,6 @@ mruby should be highly portable to other systems and compilers. For this it is
|
|||||||
recommended to keep your code as close as possible to the C99 standard
|
recommended to keep your code as close as possible to the C99 standard
|
||||||
(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf).
|
(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf).
|
||||||
|
|
||||||
Although we target C99, we've heard some compilers in the embedded environment
|
|
||||||
still requires declarations of local variables to be at the beginning of a
|
|
||||||
scope. Until we confirm the situation has changed, we use the old-style
|
|
||||||
variable declaration.
|
|
||||||
|
|
||||||
Visual C++ is also an important target for mruby (supported version is 2013 or
|
Visual C++ is also an important target for mruby (supported version is 2013 or
|
||||||
later). For this reason features that are not supported by Visual C++ may not
|
later). For this reason features that are not supported by Visual C++ may not
|
||||||
be used (e.g. `%z` of `strftime()`).
|
be used (e.g. `%z` of `strftime()`).
|
||||||
@@ -50,19 +46,15 @@ The dependencies to libraries should be kept to an absolute minimum. This
|
|||||||
increases the portability but makes it also easier to cut away parts of mruby
|
increases the portability but makes it also easier to cut away parts of mruby
|
||||||
on-demand.
|
on-demand.
|
||||||
|
|
||||||
#### Don't use C++ style comments
|
#### Insert a break after the function return value:
|
||||||
|
|
||||||
/* This is the preferred comment style */
|
|
||||||
|
|
||||||
Use C++ style comments only for temporary comment e.g. commenting out some code lines.
|
|
||||||
|
|
||||||
#### Insert a break after the method return value:
|
|
||||||
|
|
||||||
|
```C
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Ruby code
|
### Ruby code
|
||||||
|
|
||||||
@@ -72,4 +64,5 @@ language itself. Please note the following hints for your Ruby code:
|
|||||||
#### Comply with the Ruby standard (ISO/IEC 30170:2012)
|
#### Comply with the Ruby standard (ISO/IEC 30170:2012)
|
||||||
|
|
||||||
mruby is currently targeting to execute Ruby code which complies to ISO/IEC
|
mruby is currently targeting to execute Ruby code which complies to ISO/IEC
|
||||||
30170:2012 (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579).
|
30170:2012 (https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579),
|
||||||
|
unless there's a clear reason, e.g. the latest Ruby has changed behavior from ISO.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
DOXYFILE_ENCODING = UTF-8
|
DOXYFILE_ENCODING = UTF-8
|
||||||
PROJECT_NAME = "mruby"
|
PROJECT_NAME = "mruby"
|
||||||
PROJECT_NUMBER = 2.1.2
|
PROJECT_NUMBER = 3.0.0
|
||||||
|
|
||||||
PROJECT_BRIEF = "mruby is the lightweight implementation of the Ruby language"
|
PROJECT_BRIEF = "mruby is the lightweight implementation of the Ruby language"
|
||||||
|
|
||||||
@@ -27,12 +27,12 @@ INPUT = README.md \
|
|||||||
# Red for Ruby
|
# Red for Ruby
|
||||||
HTML_COLORSTYLE_HUE = 359
|
HTML_COLORSTYLE_HUE = 359
|
||||||
|
|
||||||
# The following expansions
|
# The following expansions
|
||||||
ENABLE_PREPROCESSING = YES
|
ENABLE_PREPROCESSING = YES
|
||||||
MACRO_EXPANSION = YES
|
MACRO_EXPANSION = YES
|
||||||
EXPAND_ONLY_PREDEF = NO
|
EXPAND_ONLY_PREDEF = NO
|
||||||
PREDEFINED =
|
PREDEFINED =
|
||||||
EXPAND_AS_DEFINED =
|
EXPAND_AS_DEFINED =
|
||||||
SKIP_FUNCTION_MACROS = NO
|
SKIP_FUNCTION_MACROS = NO
|
||||||
|
|
||||||
# This tells doxygen to search the places that make sense
|
# This tells doxygen to search the places that make sense
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2020 mruby developers
|
Copyright (c) 2010-2021 mruby developers
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
|
# mruby is using Rake (https://ruby.github.io/rake/) as a build tool.
|
||||||
|
|
||||||
RAKE = rake
|
RAKE = rake
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ of the Ministry of Economy, Trade and Industry of Japan.
|
|||||||
|
|
||||||
## How to get mruby
|
## How to get mruby
|
||||||
|
|
||||||
The stable version 2.1.2 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.1.2.zip](https://github.com/mruby/mruby/archive/2.1.2.zip)
|
The stable version 3.0.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.0.0.zip](https://github.com/mruby/mruby/archive/3.0.0.zip)
|
||||||
|
|
||||||
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
|
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
|
||||||
|
|
||||||
@@ -36,20 +36,10 @@ The URL of the mruby home-page is: https://mruby.org.
|
|||||||
|
|
||||||
We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby/issues).
|
We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby/issues).
|
||||||
|
|
||||||
## How to compile and install (mruby and gems)
|
## How to compile, test, and install (mruby and gems)
|
||||||
|
|
||||||
See the [compile.md](https://github.com/mruby/mruby/blob/master/doc/guides/compile.md) file.
|
See the [compile.md](https://github.com/mruby/mruby/blob/master/doc/guides/compile.md) file.
|
||||||
|
|
||||||
## Running Tests
|
|
||||||
|
|
||||||
To run the tests, execute the following from the project's root directory.
|
|
||||||
|
|
||||||
$ rake test
|
|
||||||
|
|
||||||
Note: `bison` bundled with MacOS is too old to compile `mruby`.
|
|
||||||
Try `brew install bison` and follow the instuction shown to update
|
|
||||||
the `$PATH` to compile `mruby`.
|
|
||||||
|
|
||||||
## Building documentation
|
## Building documentation
|
||||||
|
|
||||||
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
|
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
|
||||||
@@ -94,12 +84,12 @@ Please ask us if you want to distribute your code under another license.
|
|||||||
## How to Contribute
|
## How to Contribute
|
||||||
|
|
||||||
See the [contribution guidelines][contribution-guidelines], and then send a pull
|
See the [contribution guidelines][contribution-guidelines], and then send a pull
|
||||||
request to <http://github.com/mruby/mruby>. We consider you have granted
|
request to <https://github.com/mruby/mruby>. We consider you have granted
|
||||||
non-exclusive right to your contributed code under MIT license. If you want to
|
non-exclusive right to your contributed code under MIT license. If you want to
|
||||||
be named as one of mruby developers, please include an update to the AUTHORS
|
be named as one of mruby developers, please include an update to the AUTHORS
|
||||||
file in your pull request.
|
file in your pull request.
|
||||||
|
|
||||||
[ISO-standard]: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
|
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
|
||||||
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
|
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
|
||||||
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
|
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
|
||||||
[travis-ci]: https://travis-ci.org/mruby/mruby
|
[travis-ci]: https://travis-ci.org/mruby/mruby
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT
|
|||||||
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
|
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
|
||||||
|
|
||||||
# load build systems
|
# load build systems
|
||||||
require "mruby-core-ext"
|
require "mruby/core_ext"
|
||||||
require "mruby/build"
|
require "mruby/build"
|
||||||
|
|
||||||
# load configuration file
|
# load configuration file
|
||||||
MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
|
MRUBY_CONFIG = MRuby::Build.mruby_config_path
|
||||||
load MRUBY_CONFIG
|
load MRUBY_CONFIG
|
||||||
|
|
||||||
# load basic rules
|
# load basic rules
|
||||||
@@ -23,138 +23,48 @@ MRuby.each_target do |build|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# load custom rules
|
# load custom rules
|
||||||
load "#{MRUBY_ROOT}/src/mruby_core.rake"
|
load "#{MRUBY_ROOT}/tasks/core.rake"
|
||||||
load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
|
load "#{MRUBY_ROOT}/tasks/mrblib.rake"
|
||||||
|
|
||||||
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
|
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
|
||||||
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
|
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
|
||||||
|
load "#{MRUBY_ROOT}/tasks/bin.rake"
|
||||||
|
load "#{MRUBY_ROOT}/tasks/presym.rake"
|
||||||
|
load "#{MRUBY_ROOT}/tasks/test.rake"
|
||||||
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
|
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
|
||||||
|
|
||||||
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
|
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
|
||||||
load "#{MRUBY_ROOT}/tasks/doc.rake"
|
load "#{MRUBY_ROOT}/tasks/doc.rake"
|
||||||
|
|
||||||
def install_D(src, dst)
|
|
||||||
rm_f dst
|
|
||||||
mkdir_p File.dirname(dst)
|
|
||||||
cp src, dst
|
|
||||||
end
|
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# generic build targets, rules
|
# generic build targets, rules
|
||||||
task :default => :all
|
task :default => :all
|
||||||
|
|
||||||
bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
|
|
||||||
|
|
||||||
depfiles = MRuby.targets['host'].bins.map do |bin|
|
|
||||||
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
|
|
||||||
source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}")
|
|
||||||
|
|
||||||
file install_path => source_path do |t|
|
|
||||||
install_D t.prerequisites.first, t.name
|
|
||||||
end
|
|
||||||
|
|
||||||
install_path
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby.each_target do |target|
|
|
||||||
gems.map do |gem|
|
|
||||||
current_dir = gem.dir.relative_path_from(Dir.pwd)
|
|
||||||
relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
|
|
||||||
current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
|
|
||||||
|
|
||||||
if current_build_dir !~ /^#{Regexp.escape(build_dir)}/
|
|
||||||
current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
|
|
||||||
end
|
|
||||||
|
|
||||||
gem.bins.each do |bin|
|
|
||||||
exec = exefile("#{build_dir}/bin/#{bin}")
|
|
||||||
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
|
|
||||||
|
|
||||||
file exec => objs + target.libraries do |t|
|
|
||||||
gem_flags = gems.map { |g| g.linker.flags }
|
|
||||||
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
|
|
||||||
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
|
|
||||||
gem_libraries = gems.map { |g| g.linker.libraries }
|
|
||||||
gem_library_paths = gems.map { |g| g.linker.library_paths }
|
|
||||||
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
|
|
||||||
end
|
|
||||||
|
|
||||||
if target == MRuby.targets['host']
|
|
||||||
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
|
|
||||||
|
|
||||||
file install_path => exec do |t|
|
|
||||||
install_D t.prerequisites.first, t.name
|
|
||||||
end
|
|
||||||
depfiles += [ install_path ]
|
|
||||||
elsif target == MRuby.targets['host-debug']
|
|
||||||
unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
|
|
||||||
install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")
|
|
||||||
|
|
||||||
file install_path => exec do |t|
|
|
||||||
install_D t.prerequisites.first, t.name
|
|
||||||
end
|
|
||||||
depfiles += [ install_path ]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
depfiles += [ exec ]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
depfiles += MRuby.targets.map { |n, t|
|
|
||||||
t.libraries
|
|
||||||
}.flatten
|
|
||||||
|
|
||||||
depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
|
|
||||||
t.bins.map { |bin| t.exefile("#{t.build_dir}/bin/#{bin}") }
|
|
||||||
}.flatten
|
|
||||||
|
|
||||||
desc "build all targets, install (locally) in-repo"
|
desc "build all targets, install (locally) in-repo"
|
||||||
task :all => depfiles do
|
task :all => :gensym do
|
||||||
|
Rake::Task[:build].invoke
|
||||||
puts
|
puts
|
||||||
puts "Build summary:"
|
puts "Build summary:"
|
||||||
puts
|
puts
|
||||||
MRuby.each_target do
|
MRuby.each_target do |build|
|
||||||
print_build_summary
|
build.print_build_summary
|
||||||
end
|
end
|
||||||
MRuby::Lockfile.write
|
MRuby::Lockfile.write
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "run all mruby tests"
|
task :build => MRuby.targets.flat_map{|_, build| build.products}
|
||||||
task :test
|
|
||||||
MRuby.each_target do
|
|
||||||
if test_enabled?
|
|
||||||
t = :"test_#{self.name}"
|
|
||||||
task t => ["all"] do
|
|
||||||
run_test
|
|
||||||
end
|
|
||||||
task :test => t
|
|
||||||
end
|
|
||||||
|
|
||||||
if bintest_enabled?
|
|
||||||
t = :"bintest_#{self.name}"
|
|
||||||
task t => ["all"] do
|
|
||||||
run_bintest
|
|
||||||
end
|
|
||||||
task :test => t
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "clean all built and in-repo installed artifacts"
|
desc "clean all built and in-repo installed artifacts"
|
||||||
task :clean do
|
task :clean do
|
||||||
MRuby.each_target do |t|
|
MRuby.each_target do |build|
|
||||||
rm_rf t.build_dir
|
rm_rf build.build_dir
|
||||||
|
rm_f build.products
|
||||||
end
|
end
|
||||||
rm_f depfiles
|
|
||||||
puts "Cleaned up target build folder"
|
puts "Cleaned up target build folder"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "clean everything!"
|
desc "clean everything!"
|
||||||
task :deep_clean => ["clean", "clean_doc"] do
|
task :deep_clean => %w[clean doc:clean] do
|
||||||
MRuby.each_target do |t|
|
MRuby.each_target do |build|
|
||||||
rm_rf t.gem_clone_dir
|
rm_rf build.gem_clone_dir
|
||||||
end
|
end
|
||||||
puts "Cleaned up mrbgems build folder"
|
puts "Cleaned up mrbgems build folder"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
Things to do (Things that are not done yet)
|
|
||||||
|
|
||||||
* special variables ($1,$2..)
|
|
||||||
* super in aliased methods
|
|
||||||
|
|
||||||
Things to improve (Done but things to fix)
|
|
||||||
|
|
||||||
* Make additions as they are noticed.
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
Thing to Do in the future
|
||||||
|
===
|
||||||
|
|
||||||
|
# After mruby 3.0
|
||||||
|
|
||||||
|
* replace `fp_fmt.c` by `float_format` (https://github.com/dhylands/format-float.git)
|
||||||
|
* multi-precision integer
|
||||||
|
* WORD_BOXING: Pack some floats in `mrb_value`
|
||||||
|
* NAN_BOXING: Allow `MRB_INT64` along with NaN boxing
|
||||||
|
* keyword arguments a la Ruby3.0 (using `OP_SENDVK`)
|
||||||
|
* parser and code generator independent from `mrb_state` (mmruby?)
|
||||||
|
|
||||||
|
# Things to do (Things that are not done yet)
|
||||||
|
|
||||||
|
* `begin ... end while cond` to behave as CRuby
|
||||||
|
* special variables ($1,$2..)
|
||||||
|
* super in aliased methods
|
||||||
+30
-24
@@ -1,39 +1,45 @@
|
|||||||
version: "{build}"
|
version: "{build}"
|
||||||
|
|
||||||
os: Visual Studio 2017
|
|
||||||
|
|
||||||
shallow_clone: true
|
shallow_clone: true
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
# Visual Studio 2017 64bit
|
- job_name: Visual Studio 2019 64bit
|
||||||
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2019
|
||||||
|
|
||||||
# Visual Studio 2017 32bit
|
- job_name: Visual Studio 2019 32bit
|
||||||
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2019
|
||||||
|
|
||||||
|
- job_name: Visual Studio 2017 64bit
|
||||||
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2017
|
||||||
|
|
||||||
|
- job_name: Visual Studio 2017 32bit
|
||||||
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2017
|
||||||
|
|
||||||
|
- job_name: Visual Studio 2015 64bit
|
||||||
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2015
|
||||||
|
machine: x86_amd64
|
||||||
|
|
||||||
|
- job_name: Visual Studio 2015 32bit
|
||||||
|
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
|
||||||
|
appveyor_build_worker_image: Visual Studio 2015
|
||||||
machine: x86
|
machine: x86
|
||||||
|
|
||||||
# Visual Studio 2015 64bit
|
|
||||||
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
|
|
||||||
machine: amd64
|
|
||||||
|
|
||||||
# Visual Studio 2015 32bit
|
|
||||||
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
|
|
||||||
machine: x86
|
|
||||||
|
|
||||||
# Visual Studio 2013 64bit
|
|
||||||
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
|
|
||||||
machine: amd64
|
|
||||||
|
|
||||||
|
|
||||||
init:
|
init:
|
||||||
- call "%visualcpp%" %machine%
|
- call "%visualcpp%" %machine%
|
||||||
# For using Rubyinstaller's Ruby 2.4 64bit
|
# For using Rubyins4aller's Ruby 2.6 64bit
|
||||||
- set PATH=C:\Ruby24-x64\bin;%PATH%
|
# 2.6 is the highest supported Ruby version across all historical
|
||||||
|
# Visual Studio AppVeyor images. Ruby 2.7 is only on the 2019 image.
|
||||||
|
- set PATH=C:\Ruby26-x64\bin;%PATH%
|
||||||
- ruby --version
|
- ruby --version
|
||||||
|
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- set MRUBY_CONFIG=appveyor_config.rb
|
- set MRUBY_CONFIG=ci/msvc
|
||||||
- rake -m
|
- rake -m test:build
|
||||||
- rake -E $stdout.sync=true test
|
- rake test:run
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
def setup_option(conf)
|
|
||||||
conf.cc.flags[0].delete("/Zi") unless ENV['CFLAGS']
|
|
||||||
conf.cxx.flags[0].delete("/Zi") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
|
|
||||||
conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('full-debug') do |conf|
|
|
||||||
toolchain :visualcpp
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include all core GEMs
|
|
||||||
conf.gembox 'full-core'
|
|
||||||
conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK)
|
|
||||||
setup_option(conf)
|
|
||||||
|
|
||||||
conf.enable_test
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new do |conf|
|
|
||||||
toolchain :visualcpp
|
|
||||||
|
|
||||||
# include all core GEMs
|
|
||||||
conf.gembox 'full-core'
|
|
||||||
conf.compilers.each do |c|
|
|
||||||
c.defines += %w(MRB_GC_FIXED_ARENA)
|
|
||||||
end
|
|
||||||
setup_option(conf)
|
|
||||||
conf.enable_bintest
|
|
||||||
conf.enable_test
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('cxx_abi') do |conf|
|
|
||||||
toolchain :visualcpp
|
|
||||||
|
|
||||||
conf.gembox 'full-core'
|
|
||||||
conf.compilers.each do |c|
|
|
||||||
c.defines += %w(MRB_GC_FIXED_ARENA)
|
|
||||||
end
|
|
||||||
setup_option(conf)
|
|
||||||
conf.enable_bintest
|
|
||||||
conf.enable_test
|
|
||||||
|
|
||||||
enable_cxx_abi
|
|
||||||
|
|
||||||
build_mrbc_exec
|
|
||||||
end
|
|
||||||
@@ -260,7 +260,7 @@ class Scene
|
|||||||
w.times do |x|
|
w.times do |x|
|
||||||
rad = Vec.new(0.0, 0.0, 0.0)
|
rad = Vec.new(0.0, 0.0, 0.0)
|
||||||
|
|
||||||
# Subsmpling
|
# Subsampling
|
||||||
nsubsamples.times do |v|
|
nsubsamples.times do |v|
|
||||||
nsubsamples.times do |u|
|
nsubsamples.times do |u|
|
||||||
cnt = cnt + 1
|
cnt = cnt + 1
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('no_boxing') do |conf|
|
|
||||||
toolchain :gcc
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('word_boxing') do |conf|
|
|
||||||
toolchain :gcc
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
conf.compilers.each do |c|
|
|
||||||
c.defines += %w(MRB_WORD_BOXING)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('nan_boxing') do |conf|
|
|
||||||
toolchain :gcc
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
conf.compilers.each do |c|
|
|
||||||
c.defines += %w(MRB_NAN_BOXING)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
+8
-151
@@ -1,152 +1,9 @@
|
|||||||
MRuby::Build.new do |conf|
|
# The default build configuration file was moved to `build_config/default.rb`.
|
||||||
# load specific toolchain settings
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
# Turn on `enable_debug` for better debugging
|
|
||||||
# enable_debug
|
|
||||||
|
|
||||||
# Use mrbgems
|
|
||||||
# conf.gem 'examples/mrbgems/ruby_extension_example'
|
|
||||||
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
|
|
||||||
# g.cc.flags << '-g' # append cflags in this gem
|
|
||||||
# end
|
|
||||||
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
|
|
||||||
# conf.gem :core => 'mruby-eval'
|
|
||||||
# conf.gem :mgem => 'mruby-onig-regexp'
|
|
||||||
# conf.gem :github => 'mattn/mruby-onig-regexp'
|
|
||||||
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
# C compiler settings
|
|
||||||
# conf.cc do |cc|
|
|
||||||
# cc.command = ENV['CC'] || 'gcc'
|
|
||||||
# cc.flags = [ENV['CFLAGS'] || %w()]
|
|
||||||
# cc.include_paths = ["#{root}/include"]
|
|
||||||
# cc.defines = %w()
|
|
||||||
# cc.option_include_path = %q[-I"%s"]
|
|
||||||
# cc.option_define = '-D%s'
|
|
||||||
# cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"]
|
|
||||||
# end
|
|
||||||
|
|
||||||
# mrbc settings
|
|
||||||
# conf.mrbc do |mrbc|
|
|
||||||
# mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Linker settings
|
|
||||||
# conf.linker do |linker|
|
|
||||||
# linker.command = ENV['LD'] || 'gcc'
|
|
||||||
# linker.flags = [ENV['LDFLAGS'] || []]
|
|
||||||
# linker.flags_before_libraries = []
|
|
||||||
# linker.libraries = %w()
|
|
||||||
# linker.flags_after_libraries = []
|
|
||||||
# linker.library_paths = []
|
|
||||||
# linker.option_library = '-l%s'
|
|
||||||
# linker.option_library_path = '-L%s'
|
|
||||||
# linker.link_options = "%{flags} -o "%{outfile}" %{objs} %{libs}"
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Archiver settings
|
|
||||||
# conf.archiver do |archiver|
|
|
||||||
# archiver.command = ENV['AR'] || 'ar'
|
|
||||||
# archiver.archive_options = 'rs "%{outfile}" %{objs}'
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Parser generator settings
|
|
||||||
# conf.yacc do |yacc|
|
|
||||||
# yacc.command = ENV['YACC'] || 'bison'
|
|
||||||
# yacc.compile_options = %q[-o "%{outfile}" "%{infile}"]
|
|
||||||
# end
|
|
||||||
|
|
||||||
# gperf settings
|
|
||||||
# conf.gperf do |gperf|
|
|
||||||
# gperf.command = 'gperf'
|
|
||||||
# gperf.compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"]
|
|
||||||
# end
|
|
||||||
|
|
||||||
# file extensions
|
|
||||||
# conf.exts do |exts|
|
|
||||||
# exts.object = '.o'
|
|
||||||
# exts.executable = '' # '.exe' if Windows
|
|
||||||
# exts.library = '.a'
|
|
||||||
# end
|
|
||||||
|
|
||||||
# file separetor
|
|
||||||
# conf.file_separator = '/'
|
|
||||||
|
|
||||||
# bintest
|
|
||||||
# conf.enable_bintest
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('host-debug') do |conf|
|
|
||||||
# load specific toolchain settings
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
|
|
||||||
# C compiler settings
|
|
||||||
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
|
|
||||||
|
|
||||||
# Generate mruby debugger command (require mruby-eval)
|
|
||||||
conf.gem :core => "mruby-bin-debugger"
|
|
||||||
|
|
||||||
# bintest
|
|
||||||
# conf.enable_bintest
|
|
||||||
end
|
|
||||||
|
|
||||||
MRuby::Build.new('test') do |conf|
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
conf.enable_bintest
|
|
||||||
conf.enable_test
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
#MRuby::Build.new('bench') do |conf|
|
|
||||||
# # Gets set by the VS command prompts.
|
|
||||||
# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
# toolchain :visualcpp
|
|
||||||
# else
|
|
||||||
# toolchain :gcc
|
|
||||||
# conf.cc.flags << '-O3'
|
|
||||||
# end
|
|
||||||
#
|
#
|
||||||
# conf.gembox 'default'
|
# Recommended way to customize the build configuration is:
|
||||||
#end
|
# * copy `default.rb` (or any config file) to a new file (e.g. `myconfig.rb`)
|
||||||
|
# * edit `myconfig.rb`.
|
||||||
# Define cross build settings
|
# * `rake MRUBY_CONFIG=/path/to/myconfig.rb` to compile and test.
|
||||||
# MRuby::CrossBuild.new('32bit') do |conf|
|
# * or `rake MRUBY_CONFIG=myconfig` if your configuration file is in the `build_config` directory.
|
||||||
# toolchain :gcc
|
# * (optional) submit your configuration as a pull-request if it's useful for others
|
||||||
#
|
raise "The default configuration was moved to `build_config/default.rb`"
|
||||||
# conf.cc.flags << "-m32"
|
|
||||||
# conf.linker.flags << "-m32"
|
|
||||||
#
|
|
||||||
# conf.build_mrbtest_lib_only
|
|
||||||
#
|
|
||||||
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
|
|
||||||
#
|
|
||||||
# conf.test_runner.command = 'env'
|
|
||||||
# end
|
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Cross Compiling configuration for Arduino Due
|
# Cross Compiling configuration for Arduino Due
|
||||||
# http://arduino.cc/en/Main/ArduinoBoardDue
|
# https://arduino.cc/en/Main/ArduinoBoardDue
|
||||||
#
|
#
|
||||||
# Requires Arduino IDE >= 1.5
|
# Requires Arduino IDE >= 1.5
|
||||||
MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
||||||
@@ -47,9 +31,8 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
|||||||
#configuration for low memory environment
|
#configuration for low memory environment
|
||||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
|
||||||
cc.defines << %w(MRB_GC_STRESS)
|
cc.defines << %w(MRB_GC_STRESS)
|
||||||
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
MRuby::Build.new do |conf|
|
MRuby::Build.new do |conf|
|
||||||
toolchain :gcc
|
toolchain :gcc
|
||||||
conf.gembox 'default'
|
conf.gembox 'default'
|
||||||
conf.cc.defines = %w(ENABLE_READLINE)
|
conf.cc.defines = %w(MRB_USE_READLINE)
|
||||||
conf.gembox 'default'
|
conf.gembox 'default'
|
||||||
|
|
||||||
#lightweight regular expression
|
#lightweight regular expression
|
||||||
@@ -33,7 +33,7 @@ MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
|
|||||||
cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
|
cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
|
||||||
cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
|
cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
|
||||||
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
||||||
cc.defines = %w(ENABLE_READLINE)
|
cc.defines = %w(MRB_USE_READLINE)
|
||||||
end
|
end
|
||||||
|
|
||||||
conf.cxx do |cxx|
|
conf.cxx do |cxx|
|
||||||
@@ -1,22 +1,5 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# Cross Compiling configuration for Intel Galileo on Arduino environment
|
# Cross Compiling configuration for Intel Galileo on Arduino environment
|
||||||
# http://arduino.cc/en/ArduinoCertified/IntelGalileo
|
# https://arduino.cc/en/ArduinoCertified/IntelGalileo
|
||||||
#
|
#
|
||||||
# Requires Arduino IDE for Intel Galileo
|
# Requires Arduino IDE for Intel Galileo
|
||||||
MRuby::CrossBuild.new("Galileo") do |conf|
|
MRuby::CrossBuild.new("Galileo") do |conf|
|
||||||
@@ -1,19 +1,3 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Cross Compiling configuration for RX630
|
# Cross Compiling configuration for RX630
|
||||||
# http://gadget.renesas.com/
|
# http://gadget.renesas.com/
|
||||||
#
|
#
|
||||||
@@ -30,12 +14,11 @@ MRuby::CrossBuild.new("RX630") do |conf|
|
|||||||
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
||||||
|
|
||||||
#configuration for low memory environment
|
#configuration for low memory environment
|
||||||
cc.defines << %w(MRB_USE_FLOAT)
|
cc.defines << %w(MRB_USE_FLOAT32)
|
||||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
|
||||||
cc.defines << %w(MRB_GC_STRESS)
|
cc.defines << %w(MRB_GC_STRESS)
|
||||||
cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Requires Android NDK r13 or later.
|
||||||
|
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
|
||||||
|
params = {
|
||||||
|
:arch => 'arm64-v8a',
|
||||||
|
:platform => 'android-24',
|
||||||
|
:toolchain => :clang,
|
||||||
|
}
|
||||||
|
toolchain :android, params
|
||||||
|
|
||||||
|
conf.gembox 'default'
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Requires Android NDK r13 or later.
|
||||||
|
MRuby::CrossBuild.new('android-armeabi') do |conf|
|
||||||
|
params = {
|
||||||
|
:arch => 'armeabi',
|
||||||
|
:platform => 'android-24',
|
||||||
|
:toolchain => :clang,
|
||||||
|
}
|
||||||
|
toolchain :android, params
|
||||||
|
|
||||||
|
conf.gembox 'default'
|
||||||
|
end
|
||||||
-15
@@ -1,18 +1,3 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Requires Android NDK r13 or later.
|
# Requires Android NDK r13 or later.
|
||||||
MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
|
MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
|
||||||
params = {
|
params = {
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MRuby::Build.new('bench') do |conf|
|
||||||
|
# Gets set by the VS command prompts.
|
||||||
|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||||
|
toolchain :visualcpp
|
||||||
|
else
|
||||||
|
toolchain :gcc
|
||||||
|
conf.cc.flags << '-O3'
|
||||||
|
end
|
||||||
|
|
||||||
|
conf.gembox 'default'
|
||||||
|
end
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
boxings = %w[no word nan]
|
||||||
|
bits = [64, 32]
|
||||||
|
ints = [64, 32]
|
||||||
|
|
||||||
|
boxings.product(bits, ints) do |boxing, bit, int|
|
||||||
|
next if boxing == "nan" && int == 64
|
||||||
|
|
||||||
|
MRuby::Build.new("boxing-#{boxing}-m#{bit}-i#{int}") do |conf|
|
||||||
|
conf.toolchain :gcc
|
||||||
|
conf.gembox 'default'
|
||||||
|
conf.compilers.each do |c|
|
||||||
|
c.defines << "MRB_#{boxing.upcase}_BOXING"
|
||||||
|
c.defines << "MRB_INT#{int}"
|
||||||
|
c.flags << "-m#{bit}"
|
||||||
|
end
|
||||||
|
conf.linker.flags << "-m#{bit}"
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_test
|
||||||
|
conf.enable_bintest
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,21 +1,5 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Cross Compiling configuration for Digilent chipKIT Max32
|
# Cross Compiling configuration for Digilent chipKIT Max32
|
||||||
# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
|
# https://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
|
||||||
#
|
#
|
||||||
# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX)
|
# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX)
|
||||||
#
|
#
|
||||||
@@ -44,9 +28,8 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf|
|
|||||||
#configuration for low memory environment
|
#configuration for low memory environment
|
||||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
|
||||||
cc.defines << %w(MRB_GC_STRESS)
|
cc.defines << %w(MRB_GC_STRESS)
|
||||||
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
|
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
|
||||||
|
|
||||||
MRuby::Build.new('full-debug') do |conf|
|
MRuby::Build.new('full-debug') do |conf|
|
||||||
toolchain :gcc
|
conf.toolchain
|
||||||
enable_debug
|
conf.enable_debug
|
||||||
|
|
||||||
# include all core GEMs
|
# include all core GEMs
|
||||||
conf.gembox 'full-core'
|
conf.gembox 'full-core'
|
||||||
conf.cc.flags += %w(-Werror=declaration-after-statement)
|
conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK)
|
||||||
conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK)
|
|
||||||
|
|
||||||
conf.enable_test
|
conf.enable_test
|
||||||
end
|
end
|
||||||
|
|
||||||
MRuby::Build.new do |conf|
|
MRuby::Build.new do |conf|
|
||||||
toolchain :gcc
|
conf.toolchain
|
||||||
|
|
||||||
# include all core GEMs
|
# include all core GEMs
|
||||||
conf.gembox 'full-core'
|
conf.gembox 'full-core'
|
||||||
conf.cc.flags += %w(-Werror=declaration-after-statement)
|
conf.gem :core => 'mruby-bin-debugger'
|
||||||
conf.compilers.each do |c|
|
conf.compilers.each do |c|
|
||||||
c.defines += %w(MRB_GC_FIXED_ARENA)
|
c.defines += %w(MRB_GC_FIXED_ARENA)
|
||||||
end
|
end
|
||||||
@@ -24,17 +25,16 @@ MRuby::Build.new do |conf|
|
|||||||
end
|
end
|
||||||
|
|
||||||
MRuby::Build.new('cxx_abi') do |conf|
|
MRuby::Build.new('cxx_abi') do |conf|
|
||||||
toolchain :gcc
|
conf.toolchain
|
||||||
|
|
||||||
conf.gembox 'full-core'
|
conf.gembox 'full-core'
|
||||||
conf.cc.flags += %w(-fpermissive)
|
conf.cc.flags += %w(-fpermissive)
|
||||||
conf.compilers.each do |c|
|
conf.compilers.each do |c|
|
||||||
c.defines += %w(MRB_GC_FIXED_ARENA)
|
c.defines += %w(MRB_GC_FIXED_ARENA)
|
||||||
end
|
end
|
||||||
conf.enable_bintest
|
|
||||||
conf.enable_test
|
conf.enable_test
|
||||||
|
|
||||||
enable_cxx_abi
|
conf.enable_cxx_abi
|
||||||
|
|
||||||
build_mrbc_exec
|
conf.build_mrbc_exec
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
|
||||||
|
|
||||||
|
def setup_option(conf)
|
||||||
|
conf.cc.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS']
|
||||||
|
conf.cxx.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
|
||||||
|
conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
|
||||||
|
end
|
||||||
|
|
||||||
|
MRuby::Build.new do |conf|
|
||||||
|
conf.toolchain :visualcpp
|
||||||
|
|
||||||
|
# include all core GEMs
|
||||||
|
conf.gembox 'full-core'
|
||||||
|
conf.compilers.each do |c|
|
||||||
|
c.defines += %w(MRB_GC_FIXED_ARENA)
|
||||||
|
end
|
||||||
|
setup_option(conf)
|
||||||
|
conf.enable_bintest
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
conf.toolchain :clang
|
||||||
|
# include the GEM box
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
conf.enable_sanitizer "address,undefined"
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_bintest
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Define cross build settings
|
||||||
|
MRuby::CrossBuild.new('cross-32bit') do |conf|
|
||||||
|
conf.toolchain :gcc
|
||||||
|
|
||||||
|
conf.cc.flags << "-m32"
|
||||||
|
conf.linker.flags << "-m32"
|
||||||
|
|
||||||
|
# conf.build_mrbtest_lib_only
|
||||||
|
|
||||||
|
conf.gem :core => "mruby-bin-mruby"
|
||||||
|
conf.gem "#{MRUBY_ROOT}/examples/mrbgems/c_and_ruby_extension_example"
|
||||||
|
|
||||||
|
conf.test_runner.command = 'env'
|
||||||
|
end
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
conf.toolchain
|
||||||
|
|
||||||
|
# Use mrbgems
|
||||||
|
# conf.gem 'examples/mrbgems/ruby_extension_example'
|
||||||
|
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
|
||||||
|
# g.cc.flags << '-g' # append cflags in this gem
|
||||||
|
# end
|
||||||
|
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
|
||||||
|
# conf.gem :core => 'mruby-eval'
|
||||||
|
# conf.gem :mgem => 'mruby-onig-regexp'
|
||||||
|
# conf.gem :github => 'mattn/mruby-onig-regexp'
|
||||||
|
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
|
||||||
|
|
||||||
|
# include the GEM box
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
# C compiler settings
|
||||||
|
# conf.cc do |cc|
|
||||||
|
# cc.command = ENV['CC'] || 'gcc'
|
||||||
|
# cc.flags = [ENV['CFLAGS'] || %w()]
|
||||||
|
# cc.include_paths = ["#{root}/include"]
|
||||||
|
# cc.defines = %w()
|
||||||
|
# cc.option_include_path = %q[-I"%s"]
|
||||||
|
# cc.option_define = '-D%s'
|
||||||
|
# cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# mrbc settings
|
||||||
|
# conf.mrbc do |mrbc|
|
||||||
|
# mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Linker settings
|
||||||
|
# conf.linker do |linker|
|
||||||
|
# linker.command = ENV['LD'] || 'gcc'
|
||||||
|
# linker.flags = [ENV['LDFLAGS'] || []]
|
||||||
|
# linker.flags_before_libraries = []
|
||||||
|
# linker.libraries = %w()
|
||||||
|
# linker.flags_after_libraries = []
|
||||||
|
# linker.library_paths = []
|
||||||
|
# linker.option_library = '-l%s'
|
||||||
|
# linker.option_library_path = '-L%s'
|
||||||
|
# linker.link_options = "%{flags} -o "%{outfile}" %{objs} %{libs}"
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Archiver settings
|
||||||
|
# conf.archiver do |archiver|
|
||||||
|
# archiver.command = ENV['AR'] || 'ar'
|
||||||
|
# archiver.archive_options = 'rs "%{outfile}" %{objs}'
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Parser generator settings
|
||||||
|
# conf.yacc do |yacc|
|
||||||
|
# yacc.command = ENV['YACC'] || 'bison'
|
||||||
|
# yacc.compile_options = %q[-o "%{outfile}" "%{infile}"]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# gperf settings
|
||||||
|
# conf.gperf do |gperf|
|
||||||
|
# gperf.command = 'gperf'
|
||||||
|
# gperf.compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# file extensions
|
||||||
|
# conf.exts do |exts|
|
||||||
|
# exts.object = '.o'
|
||||||
|
# exts.executable = '' # '.exe' if Windows
|
||||||
|
# exts.library = '.a'
|
||||||
|
# end
|
||||||
|
|
||||||
|
# file separator
|
||||||
|
# conf.file_separator = '/'
|
||||||
|
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
# conf.enable_debug
|
||||||
|
conf.enable_bintest
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
# Gets set by the VS command prompts
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# Include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Cross Compiling configuration for the Sega Dreamcast
|
# Cross Compiling configuration for the Sega Dreamcast
|
||||||
# This configuration requires KallistiOS (KOS)
|
# This configuration requires KallistiOS (KOS)
|
||||||
# https://dreamcast.wiki
|
# https://dreamcast.wiki
|
||||||
@@ -25,7 +11,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
|||||||
# To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
|
# To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
|
||||||
DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
|
DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
|
||||||
MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
|
MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
|
||||||
|
|
||||||
# Setting paths
|
# Setting paths
|
||||||
DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
|
DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
|
||||||
KOS_PATH = "#{DREAMCAST_PATH}/kos"
|
KOS_PATH = "#{DREAMCAST_PATH}/kos"
|
||||||
@@ -51,16 +37,16 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
|||||||
cxx.defines = conf.cc.defines.dup
|
cxx.defines = conf.cc.defines.dup
|
||||||
cxx.compile_options = conf.cc.compile_options.dup
|
cxx.compile_options = conf.cc.compile_options.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
# Linker
|
# Linker
|
||||||
# There is an issue when making the mruby library with KallistiOS:
|
# There is an issue when making the mruby library with KallistiOS:
|
||||||
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
|
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
|
||||||
# specified here at least for now.
|
# specified here at least for now.
|
||||||
conf.linker do |linker|
|
conf.linker do |linker|
|
||||||
linker.command="#{BIN_PATH}/sh-elf-gcc"
|
linker.command="#{BIN_PATH}/sh-elf-gcc"
|
||||||
linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
|
linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
|
||||||
linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
|
linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Archiver
|
# Archiver
|
||||||
conf.archiver do |archiver|
|
conf.archiver do |archiver|
|
||||||
@@ -76,7 +62,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
|||||||
|
|
||||||
# Disable C++ exception
|
# Disable C++ exception
|
||||||
conf.disable_cxx_exception
|
conf.disable_cxx_exception
|
||||||
|
|
||||||
# Gems from core
|
# Gems from core
|
||||||
# removing mruby-io
|
# removing mruby-io
|
||||||
conf.gem :core => "mruby-metaprog"
|
conf.gem :core => "mruby-metaprog"
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# Cross Compiling configuration for the Nintendo GameBoyAdvance.
|
||||||
|
# This configuration requires devkitARM
|
||||||
|
# https://devkitpro.org/wiki/Getting_Started/devkitARM
|
||||||
|
#
|
||||||
|
# Tested only on GNU/Linux
|
||||||
|
#
|
||||||
|
MRuby::CrossBuild.new("gameboyadvance") do |conf|
|
||||||
|
toolchain :gcc
|
||||||
|
|
||||||
|
DEVKITPRO_PATH = "/opt/devkitpro"
|
||||||
|
BIN_PATH = "#{DEVKITPRO_PATH}/devkitARM/bin"
|
||||||
|
|
||||||
|
# C compiler
|
||||||
|
conf.cc do |cc|
|
||||||
|
cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
||||||
|
cc.flags << ["-mthumb-interwork", "-mthumb", "-O2"]
|
||||||
|
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
|
||||||
|
end
|
||||||
|
|
||||||
|
# C++ compiler
|
||||||
|
conf.cxx do |cxx|
|
||||||
|
cxx.command = "#{BIN_PATH}/arm-none-eabi-g++"
|
||||||
|
cxx.include_paths = conf.cc.include_paths.dup
|
||||||
|
cxx.flags = conf.cc.flags.dup
|
||||||
|
cxx.flags << %w[-fno-rtti -fno-exceptions]
|
||||||
|
cxx.defines = conf.cc.defines.dup
|
||||||
|
cxx.compile_options = conf.cc.compile_options.dup
|
||||||
|
end
|
||||||
|
|
||||||
|
# Linker
|
||||||
|
conf.linker do |linker|
|
||||||
|
linker.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
||||||
|
linker.flags << ["-mthumb-interwork", "-mthumb", "-specs=gba.specs"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# No executables
|
||||||
|
conf.bins = []
|
||||||
|
|
||||||
|
# Do not build executable test
|
||||||
|
conf.build_mrbtest_lib_only
|
||||||
|
|
||||||
|
# Disable C++ exception
|
||||||
|
conf.disable_cxx_exception
|
||||||
|
|
||||||
|
# Gems from core
|
||||||
|
# removing mruby-io
|
||||||
|
conf.gem core: "mruby-metaprog"
|
||||||
|
conf.gem core: "mruby-pack"
|
||||||
|
conf.gem core: "mruby-sprintf"
|
||||||
|
conf.gem core: "mruby-print"
|
||||||
|
conf.gem core: "mruby-math"
|
||||||
|
conf.gem core: "mruby-time"
|
||||||
|
conf.gem core: "mruby-struct"
|
||||||
|
conf.gem core: "mruby-compar-ext"
|
||||||
|
conf.gem core: "mruby-enum-ext"
|
||||||
|
conf.gem core: "mruby-string-ext"
|
||||||
|
conf.gem core: "mruby-numeric-ext"
|
||||||
|
conf.gem core: "mruby-array-ext"
|
||||||
|
conf.gem core: "mruby-hash-ext"
|
||||||
|
conf.gem core: "mruby-range-ext"
|
||||||
|
conf.gem core: "mruby-proc-ext"
|
||||||
|
conf.gem core: "mruby-symbol-ext"
|
||||||
|
conf.gem core: "mruby-random"
|
||||||
|
conf.gem core: "mruby-object-ext"
|
||||||
|
conf.gem core: "mruby-objectspace"
|
||||||
|
conf.gem core: "mruby-fiber"
|
||||||
|
conf.gem core: "mruby-enumerator"
|
||||||
|
conf.gem core: "mruby-enum-lazy"
|
||||||
|
conf.gem core: "mruby-toplevel-ext"
|
||||||
|
conf.gem core: "mruby-kernel-ext"
|
||||||
|
conf.gem core: "mruby-class-ext"
|
||||||
|
conf.gem core: "mruby-compiler"
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
conf.toolchain
|
||||||
|
|
||||||
|
# include the default GEMs
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
# C compiler settings
|
||||||
|
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK)
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_cxx_abi
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
MRuby::Build.new('host') do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
conf.toolchain
|
||||||
|
|
||||||
|
conf.enable_debug
|
||||||
|
|
||||||
|
# include the default GEMs
|
||||||
|
conf.gembox 'full-core'
|
||||||
|
|
||||||
|
# C compiler settings
|
||||||
|
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING)
|
||||||
|
|
||||||
|
# Generate mruby debugger command (require mruby-eval)
|
||||||
|
conf.gem :core => "mruby-bin-debugger"
|
||||||
|
|
||||||
|
# test
|
||||||
|
conf.enable_test
|
||||||
|
# bintest
|
||||||
|
conf.enable_bintest
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
toolchain :gcc
|
||||||
|
|
||||||
|
# include the GEM box
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
conf.cc.flags << '-pg'
|
||||||
|
conf.linker.flags << '-pg'
|
||||||
|
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
toolchain :gcc
|
||||||
|
|
||||||
|
# include the GEM box
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
conf.cc.flags << '-m32'
|
||||||
|
conf.linker.flags << '-m32'
|
||||||
|
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_test
|
||||||
|
conf.enable_bintest
|
||||||
|
end
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
# load specific toolchain settings
|
||||||
|
|
||||||
|
# Gets set by the VS command prompts.
|
||||||
|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||||
|
toolchain :visualcpp
|
||||||
|
else
|
||||||
|
toolchain :gcc
|
||||||
|
end
|
||||||
|
|
||||||
|
# include the GEM box
|
||||||
|
conf.gembox 'default'
|
||||||
|
|
||||||
|
# C compiler settings
|
||||||
|
conf.cc do |cc|
|
||||||
|
cc.flags = '-fPIC'
|
||||||
|
end
|
||||||
|
|
||||||
|
conf.archiver do |archiver|
|
||||||
|
archiver.command = 'gcc'
|
||||||
|
archiver.archive_options = '-shared -o %{outfile} %{objs}'
|
||||||
|
end
|
||||||
|
|
||||||
|
# file extensions
|
||||||
|
conf.exts do |exts|
|
||||||
|
exts.library = '.so'
|
||||||
|
end
|
||||||
|
|
||||||
|
# file separator
|
||||||
|
# conf.file_separator = '/'
|
||||||
|
|
||||||
|
# Turn on `enable_debug` for better debugging
|
||||||
|
conf.enable_debug
|
||||||
|
conf.enable_bintest
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
MRuby::Build.new do |conf|
|
||||||
|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||||
|
conf.toolchain :visualcpp
|
||||||
|
else
|
||||||
|
conf.toolchain :gcc
|
||||||
|
end
|
||||||
|
|
||||||
|
conf.build_mrbc_exec
|
||||||
|
conf.disable_libmruby
|
||||||
|
conf.disable_presym
|
||||||
|
end
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Define cross build settings
|
||||||
|
MRuby::CrossBuild.new('no-float') do |conf|
|
||||||
|
conf.toolchain
|
||||||
|
|
||||||
|
# Add configuration
|
||||||
|
conf.compilers.each do |c|
|
||||||
|
c.defines << "MRB_NO_FLOAT"
|
||||||
|
end
|
||||||
|
|
||||||
|
conf.gem :core => "mruby-bin-mruby"
|
||||||
|
|
||||||
|
conf.test_runner.command = 'env'
|
||||||
|
|
||||||
|
conf.enable_debug
|
||||||
|
# conf.enable_bintest
|
||||||
|
conf.enable_test
|
||||||
|
end
|
||||||
+139
-50
@@ -6,45 +6,53 @@ binaries.
|
|||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
To compile mruby out of the source code you need the following tools:
|
To compile mruby out of the source code you need the following tools:
|
||||||
|
|
||||||
* C Compiler (e.g. `gcc` or `clang`)
|
* C Compiler (e.g. `gcc` or `clang`)
|
||||||
* Linker (e.g. `gcc` or `clang`)
|
* Linker (e.g. `gcc` or `clang`)
|
||||||
* Archive utility (e.g. `ar`)
|
* Archive utility (e.g. `ar`)
|
||||||
* Parser generator (e.g. `bison`)
|
* Parser generator (`bison`)
|
||||||
* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
|
* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
|
||||||
|
|
||||||
Note that `bison` bundled with MacOS is too old to compile `mruby`.
|
Note that `bison` bundled with MacOS is too old to compile `mruby`.
|
||||||
Try `brew install bison` and follow the instuction shown to update
|
Try `brew install bison` and follow the instruction shown to update
|
||||||
the `$PATH` to compile `mruby`.
|
the `$PATH` to compile `mruby`. We also encourage to upgrade `ruby`
|
||||||
|
on MacOS in similar manner.
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
* GIT (to update mruby source and integrate mrbgems easier)
|
|
||||||
|
* git (to update mruby source and integrate mrbgems easier)
|
||||||
* C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc)
|
* C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc)
|
||||||
* Assembler (to use GEMs which include \*.asm)
|
|
||||||
|
|
||||||
## Usage
|
## Build
|
||||||
|
|
||||||
|
To compile `mruby` with the default build configuration, just invoke `rake`
|
||||||
|
inside of the mruby source root. To generate and execute the test tools call
|
||||||
|
`rake test`. To clean all build files call `rake clean`. To see full command
|
||||||
|
line on build, call `rake -v`.
|
||||||
|
|
||||||
|
You can specify your own configuration file by the `MRUBY_CONFIG` environment
|
||||||
|
variable (you can use `CONFIG` for shorthand for `MRUBY_CONFIG`). If the path
|
||||||
|
doesn't exist, *build_config/${MRUBY_CONFIG}.rb* is used. The default
|
||||||
|
configuration is defined in the `build_config/default.rb` file.
|
||||||
|
|
||||||
|
Those build configuration files contain the build configuration of mruby, for
|
||||||
|
example:
|
||||||
|
|
||||||
Inside of the root directory of the mruby source a file exists
|
|
||||||
called *build_config.rb*. This file contains the build configuration
|
|
||||||
of mruby and looks like this for example:
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::Build.new do |conf|
|
MRuby::Build.new do |conf|
|
||||||
toolchain :gcc
|
conf.toolchain :gcc
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
All tools necessary to compile mruby can be set or modified here. In case
|
All tools necessary to compile mruby can be set or modified here.
|
||||||
you want to maintain an additional *build_config.rb* you can define a
|
|
||||||
customized path using the *$MRUBY_CONFIG* environment variable.
|
|
||||||
|
|
||||||
To compile just call `rake` inside of the mruby source root. To
|
|
||||||
generate and execute the test tools call `rake test`. To clean
|
|
||||||
all build files call `rake clean`. To see full command line on
|
|
||||||
build, call `rake -v`.
|
|
||||||
|
|
||||||
## Build Configuration
|
## Build Configuration
|
||||||
|
|
||||||
Inside of the *build_config.rb* the following options can be configured
|
We wish you submit a pull-request to *build_config/**PLATFORM**.rb*, once you
|
||||||
based on your environment.
|
created a new configuration for a new platform.
|
||||||
|
|
||||||
|
Inside of the configuration file, the following options can be
|
||||||
|
configured based on your environment.
|
||||||
|
|
||||||
### Toolchains
|
### Toolchains
|
||||||
|
|
||||||
@@ -54,32 +62,36 @@ configure the build environment for specific compiler infrastructures.
|
|||||||
#### GCC
|
#### GCC
|
||||||
|
|
||||||
Toolchain configuration for the GNU C Compiler.
|
Toolchain configuration for the GNU C Compiler.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
toolchain :gcc
|
conf.toolchain :gcc
|
||||||
```
|
```
|
||||||
|
|
||||||
#### clang
|
#### clang
|
||||||
|
|
||||||
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
|
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
|
||||||
GCC toolchain.
|
GCC toolchain.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
toolchain :clang
|
conf.toolchain :clang
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Visual Studio 2010, 2012 and 2013
|
#### Visual Studio 2010, 2012 and 2013
|
||||||
|
|
||||||
Toolchain configuration for Visual Studio on Windows. If you use the
|
Toolchain configuration for Visual Studio on Windows. If you use the
|
||||||
[Visual Studio Command Prompt](http://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
|
[Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
|
||||||
you normally do not have to specify this manually, since it gets automatically detected by our build process.
|
you normally do not have to specify this manually, since it gets automatically detected by our build process.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
toolchain :visualcpp
|
conf.toolchain :visualcpp
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Android
|
#### Android
|
||||||
|
|
||||||
Toolchain configuration for Android.
|
Toolchain configuration for Android.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
toolchain :android
|
conf.toolchain :android
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires the custom standalone Android NDK and the toolchain path
|
Requires the custom standalone Android NDK and the toolchain path
|
||||||
@@ -88,20 +100,18 @@ in `ANDROID_STANDALONE_TOOLCHAIN`.
|
|||||||
### Binaries
|
### Binaries
|
||||||
|
|
||||||
It is possible to select which tools should be compiled during the compilation
|
It is possible to select which tools should be compiled during the compilation
|
||||||
process. The following tools can be selected:
|
process. For example,
|
||||||
* mruby (mruby interpreter)
|
|
||||||
* mirb (mruby interactive shell)
|
|
||||||
|
|
||||||
To select them declare conf.gem as follows:
|
* `mruby`
|
||||||
```ruby
|
* `mirb`
|
||||||
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
|
|
||||||
conf.gem "#{root}/mrbgems/mruby-bin-mirb"
|
The configuration are done via `mrbgems`. See `Mrbgems` section.
|
||||||
```
|
|
||||||
|
|
||||||
### File Separator
|
### File Separator
|
||||||
|
|
||||||
Some environments require a different file separator character. It is possible to
|
Some environments require a different file separator character. It is possible to
|
||||||
set the character via `conf.file_separator`.
|
set the character via `conf.file_separator`.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.file_separator = '/'
|
conf.file_separator = '/'
|
||||||
```
|
```
|
||||||
@@ -109,6 +119,7 @@ conf.file_separator = '/'
|
|||||||
### C Compiler
|
### C Compiler
|
||||||
|
|
||||||
Configuration of the C compiler binary, flags and include paths.
|
Configuration of the C compiler binary, flags and include paths.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.cc do |cc|
|
conf.cc do |cc|
|
||||||
cc.command = ...
|
cc.command = ...
|
||||||
@@ -124,6 +135,7 @@ end
|
|||||||
C Compiler has header searcher to detect installed library.
|
C Compiler has header searcher to detect installed library.
|
||||||
|
|
||||||
If you need a include path of header file use `search_header_path`:
|
If you need a include path of header file use `search_header_path`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
# Searches ```iconv.h```.
|
# Searches ```iconv.h```.
|
||||||
# If found it will return include path of the header file.
|
# If found it will return include path of the header file.
|
||||||
@@ -132,6 +144,7 @@ fail 'iconv.h not found' unless conf.cc.search_header_path 'iconv.h'
|
|||||||
```
|
```
|
||||||
|
|
||||||
If you need a full file name of header file use `search_header`:
|
If you need a full file name of header file use `search_header`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
# Searches ```iconv.h```.
|
# Searches ```iconv.h```.
|
||||||
# If found it will return full path of the header file.
|
# If found it will return full path of the header file.
|
||||||
@@ -145,6 +158,7 @@ When you are using GCC toolchain (including clang toolchain since its base is gc
|
|||||||
it will use compiler specific include paths too. (For example `/usr/local/include`, `/usr/include`)
|
it will use compiler specific include paths too. (For example `/usr/local/include`, `/usr/include`)
|
||||||
|
|
||||||
If you need a special header search paths define a singleton method `header_search_paths` to C compiler:
|
If you need a special header search paths define a singleton method `header_search_paths` to C compiler:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
def conf.cc.header_search_paths
|
def conf.cc.header_search_paths
|
||||||
['/opt/local/include'] + include_paths
|
['/opt/local/include'] + include_paths
|
||||||
@@ -154,6 +168,7 @@ end
|
|||||||
### Linker
|
### Linker
|
||||||
|
|
||||||
Configuration of the Linker binary, flags and library paths.
|
Configuration of the Linker binary, flags and library paths.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.linker do |linker|
|
conf.linker do |linker|
|
||||||
linker.command = ...
|
linker.command = ...
|
||||||
@@ -171,6 +186,7 @@ end
|
|||||||
### Archiver
|
### Archiver
|
||||||
|
|
||||||
Configuration of the Archiver binary and flags.
|
Configuration of the Archiver binary and flags.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.archiver do |archiver|
|
conf.archiver do |archiver|
|
||||||
archiver.command = ...
|
archiver.command = ...
|
||||||
@@ -181,6 +197,7 @@ end
|
|||||||
### Parser Generator
|
### Parser Generator
|
||||||
|
|
||||||
Configuration of the Parser Generator binary and flags.
|
Configuration of the Parser Generator binary and flags.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.yacc do |yacc|
|
conf.yacc do |yacc|
|
||||||
yacc.command = ...
|
yacc.command = ...
|
||||||
@@ -191,6 +208,7 @@ end
|
|||||||
### GPerf
|
### GPerf
|
||||||
|
|
||||||
Configuration of the GPerf binary and flags.
|
Configuration of the GPerf binary and flags.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gperf do |gperf|
|
conf.gperf do |gperf|
|
||||||
gperf.command = ...
|
gperf.command = ...
|
||||||
@@ -199,6 +217,7 @@ end
|
|||||||
```
|
```
|
||||||
|
|
||||||
### File Extensions
|
### File Extensions
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.exts do |exts|
|
conf.exts do |exts|
|
||||||
exts.object = ...
|
exts.object = ...
|
||||||
@@ -207,19 +226,44 @@ conf.exts do |exts|
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Preallocated Symbols
|
||||||
|
|
||||||
|
By far, preallocate symbols are highly compatible with the previous versions, so
|
||||||
|
we expect you won't see any problem with them. But just in case you face any
|
||||||
|
issue, you can disable preallocated symbols by specifying `conf.disable_presym`.
|
||||||
|
|
||||||
|
In the build process, `mrbc` under cross compiling environment will be compiled
|
||||||
|
with this configuration.
|
||||||
|
|
||||||
### Mrbgems
|
### Mrbgems
|
||||||
|
|
||||||
Integrate GEMs in the build process.
|
`mruby` comes with the (sort of) packaging system named `mrbgems`. To
|
||||||
```ruby
|
specify `gem`, you can use `conf.gem` in the configuration file.
|
||||||
# Integrate GEM with additional configuration
|
|
||||||
conf.gem 'path/to/gem' do |g|
|
|
||||||
g.cc.flags << ...
|
|
||||||
end
|
|
||||||
|
|
||||||
# Integrate GEM without additional configuration
|
```ruby
|
||||||
conf.gem 'path/to/another/gem'
|
# Integrate a bundled Gem you see in `mrbgems` directory
|
||||||
|
conf.gem :core => 'mruby-something'
|
||||||
|
|
||||||
|
# Integrate a Gem from GitHub
|
||||||
|
conf.gem :github => 'someone/mruby-another'
|
||||||
|
|
||||||
|
# Integrate a mruby binary Gem
|
||||||
|
conf.gem :core => 'mruby-bin-mruby'
|
||||||
|
|
||||||
|
# Integrate a interactive mruby binary Gem
|
||||||
|
conf.gem :core => 'mruby-bin-mirb'
|
||||||
|
|
||||||
|
# Integrate GemBox (set of Gems)
|
||||||
|
conf.gembox "default"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A GemBox is a set of Gems defined in `mrbgems/default.gembox` for example.
|
||||||
|
It's just a set of `mrbgem` configurations.
|
||||||
|
|
||||||
|
There is a `RubyGem` (gem for CRuby) named `mgem` that help you to
|
||||||
|
manage `mrbgems`. Try `gem install mgem`. `mgem` can show you the list
|
||||||
|
of registered `mrbgems`.
|
||||||
|
|
||||||
See doc/mrbgems/README.md for more option about mrbgems.
|
See doc/mrbgems/README.md for more option about mrbgems.
|
||||||
|
|
||||||
### Mrbtest
|
### Mrbtest
|
||||||
@@ -227,6 +271,7 @@ See doc/mrbgems/README.md for more option about mrbgems.
|
|||||||
Configuration Mrbtest build process.
|
Configuration Mrbtest build process.
|
||||||
|
|
||||||
If you want mrbtest.a only, You should set `conf.build_mrbtest_lib_only`
|
If you want mrbtest.a only, You should set `conf.build_mrbtest_lib_only`
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.build_mrbtest_lib_only
|
conf.build_mrbtest_lib_only
|
||||||
```
|
```
|
||||||
@@ -239,6 +284,7 @@ See `mruby-bin-*/bintest/*.rb` if you need examples.
|
|||||||
If you want a temporary files use `tempfile` module of CRuby instead of `/tmp/`.
|
If you want a temporary files use `tempfile` module of CRuby instead of `/tmp/`.
|
||||||
|
|
||||||
You can enable it with following:
|
You can enable it with following:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.enable_bintest
|
conf.enable_bintest
|
||||||
```
|
```
|
||||||
@@ -257,6 +303,7 @@ files are compiled by C++ compiler.
|
|||||||
|
|
||||||
When you mix C++ code, C++ exception would be enabled automatically.
|
When you mix C++ code, C++ exception would be enabled automatically.
|
||||||
If you need to enable C++ exception explicitly add the following:
|
If you need to enable C++ exception explicitly add the following:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.enable_cxx_exception
|
conf.enable_cxx_exception
|
||||||
```
|
```
|
||||||
@@ -266,20 +313,24 @@ conf.enable_cxx_exception
|
|||||||
If your compiler does not support C++ and you want to ensure
|
If your compiler does not support C++ and you want to ensure
|
||||||
you don't use mrbgem written in C++, you can explicitly disable
|
you don't use mrbgem written in C++, you can explicitly disable
|
||||||
C++ exception, add following:
|
C++ exception, add following:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.disable_cxx_exception
|
conf.disable_cxx_exception
|
||||||
```
|
```
|
||||||
|
|
||||||
and you will get an error when you try to use C++ gem.
|
and you will get an error when you try to use C++ gem.
|
||||||
Note that it must be called before `enable_cxx_exception` or `gem` method.
|
Note that it must be called before `enable_cxx_exception` or `gem` method.
|
||||||
|
|
||||||
### Debugging mode
|
### Debugging mode
|
||||||
|
|
||||||
To enable debugging mode add the following:
|
To enable debugging mode add the following:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.enable_debug
|
conf.enable_debug
|
||||||
```
|
```
|
||||||
|
|
||||||
When debugging mode is enabled
|
When debugging mode is enabled
|
||||||
|
|
||||||
* Macro `MRB_DEBUG` would be defined.
|
* Macro `MRB_DEBUG` would be defined.
|
||||||
* Which means `mrb_assert()` macro is enabled.
|
* Which means `mrb_assert()` macro is enabled.
|
||||||
* Debug information of irep would be generated by `mrbc`.
|
* Debug information of irep would be generated by `mrbc`.
|
||||||
@@ -288,27 +339,29 @@ When debugging mode is enabled
|
|||||||
|
|
||||||
## Cross-Compilation
|
## Cross-Compilation
|
||||||
|
|
||||||
mruby can also be cross-compiled from one platform to another. To
|
mruby can also be cross-compiled from one platform to another. To achieve
|
||||||
achieve this the *build_config.rb* needs to contain an instance of
|
cross-compilation, the build configuration needs to contain an instance of
|
||||||
`MRuby::CrossBuild`. This instance defines the compilation
|
`MRuby::CrossBuild`. This instance defines the compilation tools and flags
|
||||||
tools and flags for the target platform. An example could look
|
for the target platform. An example could look like this:
|
||||||
like this:
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::CrossBuild.new('32bit') do |conf|
|
MRuby::CrossBuild.new('32bit') do |conf|
|
||||||
toolchain :gcc
|
conf.toolchain :gcc
|
||||||
|
|
||||||
conf.cc.flags << "-m32"
|
conf.cc.flags << "-m32"
|
||||||
conf.linker.flags << "-m32"
|
conf.linker.flags << "-m32"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
All configuration options of `MRuby::Build` can also be used
|
All configuration options of `MRuby::Build` can also be used in
|
||||||
in `MRuby::CrossBuild`.
|
`MRuby::CrossBuild`. You can find examples under the *build_config*
|
||||||
|
directory.
|
||||||
|
|
||||||
### Mrbtest in Cross-Compilation
|
### Mrbtest in Cross-Compilation
|
||||||
|
|
||||||
In cross compilation, you can run `mrbtest` on emulator if
|
In cross compilation, you can run `mrbtest` on emulator if
|
||||||
you have it by changing configuration of test runner.
|
you have it by changing configuration of test runner.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.test_runner do |t|
|
conf.test_runner do |t|
|
||||||
t.command = ... # set emulator. this value must be non nil or false
|
t.command = ... # set emulator. this value must be non nil or false
|
||||||
@@ -348,6 +401,7 @@ root directory. The structure of this directory will look like this:
|
|||||||
+- mruby
|
+- mruby
|
||||||
|
|
||||||
The compilation workflow will look like this:
|
The compilation workflow will look like this:
|
||||||
|
|
||||||
* compile all files under *src* (object files will be stored
|
* compile all files under *src* (object files will be stored
|
||||||
in *build/host/src*)
|
in *build/host/src*)
|
||||||
* generate parser grammar out of *src/parse.y* (generated
|
* generate parser grammar out of *src/parse.y* (generated
|
||||||
@@ -425,6 +479,7 @@ build directory.
|
|||||||
The cross compilation workflow starts in the same way as the normal
|
The cross compilation workflow starts in the same way as the normal
|
||||||
compilation by compiling all *native* libraries and binaries.
|
compilation by compiling all *native* libraries and binaries.
|
||||||
Afterwards the cross compilation process proceeds like this:
|
Afterwards the cross compilation process proceeds like this:
|
||||||
|
|
||||||
* cross-compile all files under *src* (object files will be stored
|
* cross-compile all files under *src* (object files will be stored
|
||||||
in *build/i386/src*)
|
in *build/i386/src*)
|
||||||
* generate parser grammar out of *src/parse.y* (generated
|
* generate parser grammar out of *src/parse.y* (generated
|
||||||
@@ -474,7 +529,7 @@ can't be disabled for the main build.
|
|||||||
MRuby::CrossBuild.new('Minimal') do |conf|
|
MRuby::CrossBuild.new('Minimal') do |conf|
|
||||||
toolchain :gcc
|
toolchain :gcc
|
||||||
|
|
||||||
conf.cc.defines = %w(MRB_DISABLE_STDIO)
|
conf.cc.defines = %w(MRB_NO_STDIO)
|
||||||
conf.bins = []
|
conf.bins = []
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@@ -490,3 +545,37 @@ of mruby, a native binary called `mrbtest` will be generated and executed.
|
|||||||
This binary contains all test cases which are defined under *test/t*. In case
|
This binary contains all test cases which are defined under *test/t*. In case
|
||||||
of a cross-compilation an additional cross-compiled *mrbtest* binary is
|
of a cross-compilation an additional cross-compiled *mrbtest* binary is
|
||||||
generated. You can copy this binary and run on your target system.
|
generated. You can copy this binary and run on your target system.
|
||||||
|
|
||||||
|
## Embedding `mruby` in Your Application
|
||||||
|
|
||||||
|
After the build, you will get `libmruby.a`. You can link it to your application.
|
||||||
|
|
||||||
|
For compiler options and library path, you can use `mruby-config` command for
|
||||||
|
convenience. `mruby-config` command prints the configuration used for `libmruby.a`.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mruby-config --help
|
||||||
|
Usage: mruby-config [switches]
|
||||||
|
switches:
|
||||||
|
--cflags print flags passed to compiler
|
||||||
|
--ldflags print flags passed to linker
|
||||||
|
--ldflags-before-libs print flags passed to linker before linked libraries
|
||||||
|
--libs print linked libraries
|
||||||
|
--libmruby-path print libmruby path
|
||||||
|
```
|
||||||
|
|
||||||
|
For example, when you have a C source file (`c.c`) and try to
|
||||||
|
compile and link it with `libmruby.a`, you can run the following command,
|
||||||
|
|
||||||
|
```
|
||||||
|
gcc `mruby-config --cflags` c.c `mruby-config --ldflags` `mruby-config --libs`
|
||||||
|
```
|
||||||
|
|
||||||
|
When you use `make`, add following lines in `Makefile`
|
||||||
|
|
||||||
|
```
|
||||||
|
MRB_CONFIG = <path-to-mruby-config>
|
||||||
|
CFLAGS = `$(MRB_CONFIG) --cflags`
|
||||||
|
LDFLAGS = `$(MRB_CONFIG) --ldflags`
|
||||||
|
LIBS = `$(MRB_CONFIG) --libs`
|
||||||
|
```
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ mrdb --version
|
$ mrdb --version
|
||||||
mruby 2.1.2 (2020-08-06)
|
mruby 3.0.0 (2021-03-05)
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2.2 Basic Operation
|
## 2.2 Basic Operation
|
||||||
@@ -220,6 +220,7 @@ Example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Enabling all breakpoints
|
Enabling all breakpoints
|
||||||
|
|
||||||
```
|
```
|
||||||
(foo.rb:1) enable 1 3
|
(foo.rb:1) enable 1 3
|
||||||
```
|
```
|
||||||
@@ -263,7 +264,7 @@ Example:
|
|||||||
|
|
||||||
```
|
```
|
||||||
(sample.rb:1) info breakpoints
|
(sample.rb:1) info breakpoints
|
||||||
Num Type Enb What
|
Num Type Enb What
|
||||||
1 breakpoint y at sample.rb:3 -> file name,line number
|
1 breakpoint y at sample.rb:3 -> file name,line number
|
||||||
2 breakpoint n in Sample_class:sample_class_method -> [class:]method name
|
2 breakpoint n in Sample_class:sample_class_method -> [class:]method name
|
||||||
3 breakpoint y in sample_global_method
|
3 breakpoint y in sample_global_method
|
||||||
@@ -273,8 +274,8 @@ Displaying the specified breakpoint number:
|
|||||||
|
|
||||||
```
|
```
|
||||||
(foo.rb:1) info breakpoints 1 3
|
(foo.rb:1) info breakpoints 1 3
|
||||||
Num Type Enb What
|
Num Type Enb What
|
||||||
1 breakpoint y at sample.rb:3
|
1 breakpoint y at sample.rb:3
|
||||||
3 breakpoint y in sample_global_method
|
3 breakpoint y in sample_global_method
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
_This is an English translation of [Matz's blog post][matz blog post]
|
_This is an English translation of [Matz's blog post][matz blog post]
|
||||||
written in Japanese._
|
written in Japanese._
|
||||||
_Some parts are updated to reflect recent changes._
|
_Some parts are updated to reflect recent changes._
|
||||||
[matz blog post]: http://www.rubyist.net/~matz/20130731.html
|
[matz blog post]: https://www.rubyist.net/~matz/20130731.html
|
||||||
|
|
||||||
When you are extending mruby using C language, you may encounter
|
When you are extending mruby using C language, you may encounter
|
||||||
mysterious "arena overflow error" or memory leak or very slow
|
mysterious "arena overflow error" or memory leak or very slow
|
||||||
|
|||||||
+50
-23
@@ -1,7 +1,9 @@
|
|||||||
# mruby configuration macros.
|
# mruby configuration macros.
|
||||||
|
|
||||||
## How to use these macros.
|
## How to use these macros.
|
||||||
|
|
||||||
You can use mrbconfs with following ways:
|
You can use mrbconfs with following ways:
|
||||||
|
|
||||||
* Write them in `mrbconf.h`.
|
* Write them in `mrbconf.h`.
|
||||||
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
|
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
|
||||||
since it's easier to use different mrbconf per each `MRuby::Build`.
|
since it's easier to use different mrbconf per each `MRuby::Build`.
|
||||||
@@ -11,7 +13,9 @@ You can use mrbconfs with following ways:
|
|||||||
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
|
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
|
||||||
|
|
||||||
## stdio setting.
|
## stdio setting.
|
||||||
`MRB_DISABLE_STDIO`
|
|
||||||
|
`MRB_NO_STDIO`
|
||||||
|
|
||||||
* When defined `<stdio.h>` functions won't be used.
|
* When defined `<stdio.h>` functions won't be used.
|
||||||
* Some features will be disabled when this is enabled:
|
* Some features will be disabled when this is enabled:
|
||||||
* `mrb_irep` load/dump from/to file.
|
* `mrb_irep` load/dump from/to file.
|
||||||
@@ -19,80 +23,97 @@ You can use mrbconfs with following ways:
|
|||||||
* Printing features in **src/print.c**.
|
* Printing features in **src/print.c**.
|
||||||
|
|
||||||
## Debug macros.
|
## Debug macros.
|
||||||
`MRB_ENABLE_DEBUG_HOOK`
|
|
||||||
|
`MRB_USE_DEBUG_HOOK`
|
||||||
|
|
||||||
* When defined code fetch hook and debug OP hook will be enabled.
|
* When defined code fetch hook and debug OP hook will be enabled.
|
||||||
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
|
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
|
||||||
* Fetch hook will be called before any OP.
|
* Fetch hook will be called before any OP.
|
||||||
* Debug OP hook will be called when dispatching `OP_DEBUG`.
|
* Debug OP hook will be called when dispatching `OP_DEBUG`.
|
||||||
|
|
||||||
`MRB_DEBUG`
|
`MRB_DEBUG`
|
||||||
|
|
||||||
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
|
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
|
||||||
* Could be enabled via `enable_debug` method of `MRuby::Build`.
|
* Could be enabled via `enable_debug` method of `MRuby::Build`.
|
||||||
|
|
||||||
## Stack configuration
|
## Stack configuration
|
||||||
|
|
||||||
`MRB_STACK_EXTEND_DOUBLING`
|
`MRB_STACK_EXTEND_DOUBLING`
|
||||||
|
|
||||||
* If defined doubles the stack size when extending it.
|
* If defined doubles the stack size when extending it.
|
||||||
* Else extends stack with `MRB_STACK_GROWTH`.
|
* Else extends stack with `MRB_STACK_GROWTH`.
|
||||||
|
|
||||||
`MRB_STACK_GROWTH`
|
`MRB_STACK_GROWTH`
|
||||||
|
|
||||||
* Default value is `128`.
|
* Default value is `128`.
|
||||||
* Used in stack extending.
|
* Used in stack extending.
|
||||||
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
|
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
|
||||||
|
|
||||||
`MRB_STACK_MAX`
|
`MRB_STACK_MAX`
|
||||||
|
|
||||||
* Default value is `0x40000 - MRB_STACK_GROWTH`.
|
* Default value is `0x40000 - MRB_STACK_GROWTH`.
|
||||||
* Raises `RuntimeError` when stack size exceeds this value.
|
* Raises `RuntimeError` when stack size exceeds this value.
|
||||||
|
|
||||||
## Primitive type configuration.
|
## Primitive type configuration.
|
||||||
|
|
||||||
`MRB_USE_FLOAT`
|
`MRB_USE_FLOAT32`
|
||||||
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
|
|
||||||
* Else double precision floating point type(C type `double`) is used as `mrb_float`.
|
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
|
||||||
|
* Otherwise double precision floating point type(C type `double`) is used as `mrb_float`.
|
||||||
|
|
||||||
|
`MRB_NO_FLOAT`
|
||||||
|
|
||||||
`MRB_WITHOUT_FLOAT`
|
|
||||||
* When defined removes floating point numbers from mruby.
|
* When defined removes floating point numbers from mruby.
|
||||||
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
|
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
|
||||||
|
|
||||||
`MRB_INT32`
|
`MRB_INT32`
|
||||||
|
|
||||||
* When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
|
* When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
|
||||||
* Conflicts with `MRB_INT64`.
|
* Conflicts with `MRB_INT64`.
|
||||||
|
|
||||||
`MRB_INT64`
|
`MRB_INT64`
|
||||||
|
|
||||||
* When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
|
* When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
|
||||||
* Conflicts with `MRB_INT32`.
|
* Conflicts with `MRB_INT32`.
|
||||||
|
|
||||||
## Garbage collector configuration.
|
## Garbage collector configuration.
|
||||||
|
|
||||||
`MRB_GC_STRESS`
|
`MRB_GC_STRESS`
|
||||||
|
|
||||||
* When defined full GC is emitted per each `RBasic` allocation.
|
* When defined full GC is emitted per each `RBasic` allocation.
|
||||||
* Mainly used in memory manager debugging.
|
* Mainly used in memory manager debugging.
|
||||||
|
|
||||||
`MRB_GC_TURN_OFF_GENERATIONAL`
|
`MRB_GC_TURN_OFF_GENERATIONAL`
|
||||||
|
|
||||||
* When defined turns generational GC by default.
|
* When defined turns generational GC by default.
|
||||||
|
|
||||||
`MRB_GC_FIXED_ARENA`
|
`MRB_GC_FIXED_ARENA`
|
||||||
|
|
||||||
* When defined used fixed size GC arena.
|
* When defined used fixed size GC arena.
|
||||||
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
|
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
|
||||||
* Useful tracking unnecessary mruby object allocation.
|
* Useful tracking unnecessary mruby object allocation.
|
||||||
|
|
||||||
`MRB_GC_ARENA_SIZE`
|
`MRB_GC_ARENA_SIZE`
|
||||||
|
|
||||||
* Default value is `100`.
|
* Default value is `100`.
|
||||||
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
|
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
|
||||||
* Defines fixed GC arena size.
|
* Defines fixed GC arena size.
|
||||||
|
|
||||||
`MRB_HEAP_PAGE_SIZE`
|
`MRB_HEAP_PAGE_SIZE`
|
||||||
|
|
||||||
* Defines value is `1024`.
|
* Defines value is `1024`.
|
||||||
* Specifies number of `RBasic` per each heap page.
|
* Specifies number of `RBasic` per each heap page.
|
||||||
|
|
||||||
## Memory pool configuration.
|
## Memory pool configuration.
|
||||||
|
|
||||||
`POOL_ALIGNMENT`
|
`POOL_ALIGNMENT`
|
||||||
|
|
||||||
* Default value is `4`.
|
* Default value is `4`.
|
||||||
* If you're allocating data types that requires alignment more than default value define the
|
* If you're allocating data types that requires alignment more than default value define the
|
||||||
largest value of required alignment.
|
largest value of required alignment.
|
||||||
|
|
||||||
`POOL_PAGE_SIZE`
|
`POOL_PAGE_SIZE`
|
||||||
|
|
||||||
* Default value is `16000`.
|
* Default value is `16000`.
|
||||||
* Specifies page size of pool page.
|
* Specifies page size of pool page.
|
||||||
* Smaller the value is increases memory overhead.
|
* Smaller the value is increases memory overhead.
|
||||||
@@ -100,37 +121,38 @@ largest value of required alignment.
|
|||||||
## State atexit configuration.
|
## State atexit configuration.
|
||||||
|
|
||||||
`MRB_FIXED_STATE_ATEXIT_STACK`
|
`MRB_FIXED_STATE_ATEXIT_STACK`
|
||||||
|
|
||||||
* If defined enables fixed size `mrb_state` atexit stack.
|
* If defined enables fixed size `mrb_state` atexit stack.
|
||||||
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
|
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
|
||||||
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
|
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
|
||||||
|
|
||||||
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
|
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
|
||||||
|
|
||||||
* Default value is `5`.
|
* Default value is `5`.
|
||||||
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
|
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
|
||||||
|
|
||||||
## `mrb_value` configuration.
|
## `mrb_value` configuration.
|
||||||
|
|
||||||
`MRB_ENDIAN_BIG`
|
`MRB_ENDIAN_BIG`
|
||||||
|
|
||||||
* If defined compiles mruby for big endian machines.
|
* If defined compiles mruby for big endian machines.
|
||||||
* Used in `MRB_NAN_BOXING`.
|
* Used in `MRB_NAN_BOXING`.
|
||||||
* Some mrbgem use this mrbconf.
|
* Some mrbgem use this mrbconf.
|
||||||
|
|
||||||
`MRB_NAN_BOXING`
|
`MRB_NAN_BOXING`
|
||||||
|
|
||||||
* If defined represent `mrb_value` in boxed `double`.
|
* If defined represent `mrb_value` in boxed `double`.
|
||||||
* Conflicts with `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`.
|
* Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
|
||||||
|
|
||||||
`MRB_WORD_BOXING`
|
`MRB_WORD_BOXING`
|
||||||
|
|
||||||
* If defined represent `mrb_value` as a word.
|
* If defined represent `mrb_value` as a word.
|
||||||
* If defined `Float` will be a mruby object with `RBasic`.
|
* If defined `Float` will be a mruby object with `RBasic`.
|
||||||
|
|
||||||
## Instance variable configuration.
|
|
||||||
`MRB_IV_SEGMENT_SIZE`
|
|
||||||
* Default value is `4`.
|
|
||||||
* Specifies size of each segment in segment list.
|
|
||||||
|
|
||||||
## Reduce heap memory configuration.
|
## Reduce heap memory configuration.
|
||||||
|
|
||||||
`MRB_USE_LINK_TIME_RO_DATA_P`
|
`MRB_USE_LINK_TIME_RO_DATA_P`
|
||||||
|
|
||||||
* Only available on ELF platforms.
|
* Only available on ELF platforms.
|
||||||
* If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is.
|
* If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is.
|
||||||
* Heap memory can be saved.
|
* Heap memory can be saved.
|
||||||
@@ -138,6 +160,7 @@ largest value of required alignment.
|
|||||||
* It must be `__ehdr_start < data_addr < __init_array_start`.
|
* It must be `__ehdr_start < data_addr < __init_array_start`.
|
||||||
|
|
||||||
`MRB_USE_CUSTOM_RO_DATA_P`
|
`MRB_USE_CUSTOM_RO_DATA_P`
|
||||||
|
|
||||||
* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`.
|
* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`.
|
||||||
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
|
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
|
||||||
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
|
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
|
||||||
@@ -145,37 +168,41 @@ largest value of required alignment.
|
|||||||
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
|
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
|
||||||
|
|
||||||
## Other configuration.
|
## Other configuration.
|
||||||
|
|
||||||
`MRB_UTF8_STRING`
|
`MRB_UTF8_STRING`
|
||||||
|
|
||||||
* Adds UTF-8 encoding support to character-oriented String instance methods.
|
* Adds UTF-8 encoding support to character-oriented String instance methods.
|
||||||
* If it isn't defined, they only support the US-ASCII encoding.
|
* If it isn't defined, they only support the US-ASCII encoding.
|
||||||
|
|
||||||
`MRB_FUNCALL_ARGC_MAX`
|
`MRB_FUNCALL_ARGC_MAX`
|
||||||
|
|
||||||
* Default value is `16`.
|
* Default value is `16`.
|
||||||
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
|
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
|
||||||
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
|
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
|
||||||
|
|
||||||
`KHASH_DEFAULT_SIZE`
|
`KHASH_DEFAULT_SIZE`
|
||||||
|
|
||||||
* Default value is `32`.
|
* Default value is `32`.
|
||||||
* Specifies default size of khash table bucket.
|
* Specifies default size of khash table bucket.
|
||||||
* Used in `kh_init_ ## name` function.
|
* Used in `kh_init_ ## name` function.
|
||||||
|
|
||||||
`MRB_STR_BUF_MIN_SIZE`
|
`MRB_NO_METHOD_CACHE`
|
||||||
* Default value is `128`.
|
|
||||||
* Specifies initial capacity of `RString` created by `mrb_str_buf_new` function..
|
|
||||||
|
|
||||||
`MRB_METHOD_CACHE`
|
* Disable method cache to save memory.
|
||||||
* Improve performance for method dispatch.
|
|
||||||
|
|
||||||
`MRB_METHOD_CACHE_SIZE`
|
`MRB_METHOD_CACHE_SIZE`
|
||||||
* Default value is `128`.
|
|
||||||
* Ignored if `MRB_METHOD_CACHE` is not defined.
|
* Default value is `256`.
|
||||||
|
* Ignored if `MRB_NO_METHOD_CACHE` is defined.
|
||||||
* Need to be the power of 2.
|
* Need to be the power of 2.
|
||||||
|
|
||||||
`MRB_METHOD_T_STRUCT`
|
`MRB_USE_METHOD_T_STRUCT`
|
||||||
|
|
||||||
* Use C struct to represent `mrb_method_t`
|
* Use C struct to represent `mrb_method_t`
|
||||||
* No `MRB_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
|
* No `MRB_USE_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
|
||||||
* Define this macro on machines that use higher bits of pointers
|
* Define this macro on machines that use higher bits of pointers
|
||||||
|
|
||||||
`MRB_ENABLE_ALL_SYMBOLS`
|
`MRB_USE_ALL_SYMBOLS`
|
||||||
* Make it available `Symbols.all_symbols` in `mrbgems/mruby-symbol-ext`
|
|
||||||
|
* Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
|
||||||
* Increase heap memory usage.
|
* Increase heap memory usage.
|
||||||
|
|||||||
+31
-14
@@ -5,21 +5,27 @@ standardised way into mruby.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
By default mrbgems is currently deactivated. As soon as you add a GEM to your
|
You have to activate mrbgems explicitly in your build configuration. To add
|
||||||
build configuration (i.e. *build_config.rb*), mrbgems will be activated and the
|
a GEM, add the following line to your build configuration file, for example:
|
||||||
extension integrated.
|
|
||||||
|
|
||||||
To add a GEM into the *build_config.rb* add the following line for example:
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem '/path/to/your/gem/dir'
|
conf.gem '/path/to/your/gem/dir'
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use a relative path which would be relative from the mruby root:
|
You can also use a relative path to specify a gem.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem 'examples/mrbgems/ruby_extension_example'
|
conf.gem 'examples/mrbgems/ruby_extension_example'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In that case,
|
||||||
|
|
||||||
|
* if your build configuration file is in the `build_config` directory, it's
|
||||||
|
relative from `MRUBY_ROOT`.
|
||||||
|
* otherwise, it is relative from the directory where your build configuration is.
|
||||||
|
|
||||||
A remote GIT repository location for a GEM is also supported:
|
A remote GIT repository location for a GEM is also supported:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem :git => 'https://github.com/masuidrive/mrbgems-example.git', :branch => 'master'
|
conf.gem :git => 'https://github.com/masuidrive/mrbgems-example.git', :branch => 'master'
|
||||||
conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
|
conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
|
||||||
@@ -27,17 +33,20 @@ conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
|
|||||||
```
|
```
|
||||||
|
|
||||||
You can specify the sub directory of the repository with `:path` option:
|
You can specify the sub directory of the repository with `:path` option:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem github: 'mruby/mruby', path: 'mrbgems/mruby-socket'
|
conf.gem github: 'mruby/mruby', path: 'mrbgems/mruby-socket'
|
||||||
```
|
```
|
||||||
|
|
||||||
To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option:
|
To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem :mgem => 'mruby-yaml'
|
conf.gem :mgem => 'mruby-yaml'
|
||||||
conf.gem :mgem => 'yaml' # 'mruby-' prefix could be omitted
|
conf.gem :mgem => 'yaml' # 'mruby-' prefix could be omitted
|
||||||
```
|
```
|
||||||
|
|
||||||
For specifying commit hash to checkout use `:checksum_hash` option:
|
For specifying commit hash to checkout use `:checksum_hash` option:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c42f2f4e'
|
conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c42f2f4e'
|
||||||
```
|
```
|
||||||
@@ -54,13 +63,14 @@ NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
|
|||||||
|
|
||||||
There are instances when you wish to add a collection of mrbgems into mruby at
|
There are instances when you wish to add a collection of mrbgems into mruby at
|
||||||
once, or be able to substitute mrbgems based on configuration, without having to
|
once, or be able to substitute mrbgems based on configuration, without having to
|
||||||
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
|
add each gem to your build configuration file. A packaged collection of mrbgems
|
||||||
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
|
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
|
||||||
into mruby, in the same format as if you were adding them to *build_config.rb*
|
into mruby, in the same format as if you were adding them to the build config
|
||||||
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
|
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
|
||||||
loaded into mruby via `config.gembox 'boxname'`.
|
loaded into mruby via `config.gembox 'boxname'`.
|
||||||
|
|
||||||
Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
|
Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::GemBox.new do |conf|
|
MRuby::GemBox.new do |conf|
|
||||||
conf.gem "#{root}/mrbgems/mruby-time"
|
conf.gem "#{root}/mrbgems/mruby-time"
|
||||||
@@ -73,16 +83,19 @@ must be saved with a *.gembox* extension inside the *mrbgems* directory to to be
|
|||||||
picked up by mruby.
|
picked up by mruby.
|
||||||
|
|
||||||
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
|
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
|
||||||
directory in mruby, and add the following to our *build_config.rb* file inside
|
directory in mruby, and add the following to your build configuration file inside
|
||||||
the build block:
|
the build block:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gembox 'custom'
|
conf.gembox 'custom'
|
||||||
```
|
```
|
||||||
|
|
||||||
This will cause the *custom* GemBox to be read in during the build process,
|
This will cause the *custom* GemBox to be read in during the build process,
|
||||||
adding *mruby-time* and *mrbgems-example* to the build.
|
adding *mruby-time* and *mrbgems-example* to the build.
|
||||||
|
|
||||||
If you want, you can put GemBox outside of mruby directory. In that case you must
|
If you want, you can put GemBox outside of mruby directory. In that case you must
|
||||||
specify an absolute path like below.
|
specify an absolute path like below.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
|
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
|
||||||
```
|
```
|
||||||
@@ -120,6 +133,7 @@ to compile C and Ruby files. *README.md* is a short description of your GEM.
|
|||||||
|
|
||||||
mrbgems expects a specification file called *mrbgem.rake* inside of your
|
mrbgems expects a specification file called *mrbgem.rake* inside of your
|
||||||
GEM directory. A typical GEM specification could look like this for example:
|
GEM directory. A typical GEM specification could look like this for example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||||
spec.license = 'MIT'
|
spec.license = 'MIT'
|
||||||
@@ -149,6 +163,7 @@ The `license` and `author` properties are required in every GEM!
|
|||||||
|
|
||||||
In case your GEM is depending on other GEMs please use
|
In case your GEM is depending on other GEMs please use
|
||||||
`spec.add_dependency(gem, *requirements[, default_get_info])` like:
|
`spec.add_dependency(gem, *requirements[, default_get_info])` like:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||||
spec.license = 'MIT'
|
spec.license = 'MIT'
|
||||||
@@ -158,10 +173,10 @@ MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
|||||||
# The version must be between 1.0.0 and 1.5.2 .
|
# The version must be between 1.0.0 and 1.5.2 .
|
||||||
spec.add_dependency('mruby-parser', '>= 1.0.0', '<= 1.5.2')
|
spec.add_dependency('mruby-parser', '>= 1.0.0', '<= 1.5.2')
|
||||||
|
|
||||||
# Use any version of mruby-uv from github.
|
# Use any version of mruby-uv from GitHub.
|
||||||
spec.add_dependency('mruby-uv', '>= 0.0.0', :github => 'mattn/mruby-uv')
|
spec.add_dependency('mruby-uv', '>= 0.0.0', :github => 'mattn/mruby-uv')
|
||||||
|
|
||||||
# Use latest mruby-onig-regexp from github. (version requirements can be omitted)
|
# Use latest mruby-onig-regexp from GitHub. (version requirements can be omitted)
|
||||||
spec.add_dependency('mruby-onig-regexp', :github => 'mattn/mruby-onig-regexp')
|
spec.add_dependency('mruby-onig-regexp', :github => 'mattn/mruby-onig-regexp')
|
||||||
|
|
||||||
# You can add extra mgems active only on test
|
# You can add extra mgems active only on test
|
||||||
@@ -172,6 +187,7 @@ end
|
|||||||
The version requirements and default gem information are optional.
|
The version requirements and default gem information are optional.
|
||||||
|
|
||||||
Version requirement supports following operators:
|
Version requirement supports following operators:
|
||||||
|
|
||||||
* '=': is equal
|
* '=': is equal
|
||||||
* '!=': is not equal
|
* '!=': is not equal
|
||||||
* '>': is greater
|
* '>': is greater
|
||||||
@@ -184,18 +200,20 @@ Version requirement supports following operators:
|
|||||||
|
|
||||||
When more than one version requirements is passed, the dependency must satisfy all of it.
|
When more than one version requirements is passed, the dependency must satisfy all of it.
|
||||||
|
|
||||||
You can have default gem to use as dependency when it's not defined in *build_config.rb*.
|
You can have default gem to use as dependency when it's not defined in your build configuration.
|
||||||
When the last argument of `add_dependency` call is `Hash`, it will be treated as default gem information.
|
When the last argument of `add_dependency` call is `Hash`, it will be treated as default gem information.
|
||||||
Its format is same as argument of method `MRuby::Build#gem`, expect that it can't be treated as path gem location.
|
Its format is same as argument of method `MRuby::Build#gem`, expect that it can't be treated as path gem location.
|
||||||
|
|
||||||
When a special version of dependency is required,
|
When a special version of dependency is required,
|
||||||
use `MRuby::Build#gem` in *build_config.rb* to override default gem.
|
use `MRuby::Build#gem` in the build configuration to override default gem.
|
||||||
|
|
||||||
If you have conflicting GEMs use the following method:
|
If you have conflicting GEMs use the following method:
|
||||||
|
|
||||||
* `spec.add_conflict(gem, *requirements)`
|
* `spec.add_conflict(gem, *requirements)`
|
||||||
* The `requirements` argument is same as in `add_dependency` method.
|
* The `requirements` argument is same as in `add_dependency` method.
|
||||||
|
|
||||||
like following code:
|
like following code:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
MRuby::Gem::Specification.new 'some-regexp-binding' do |spec|
|
MRuby::Gem::Specification.new 'some-regexp-binding' do |spec|
|
||||||
spec.license = 'BSD'
|
spec.license = 'BSD'
|
||||||
@@ -238,7 +256,6 @@ For example: when B depends to C and A depends to B, A will get include paths ex
|
|||||||
Exported include_paths are automatically appended to GEM local include_paths by rake.
|
Exported include_paths are automatically appended to GEM local include_paths by rake.
|
||||||
You can use `spec.export_include_paths` accessor if you want more complex build.
|
You can use `spec.export_include_paths` accessor if you want more complex build.
|
||||||
|
|
||||||
|
|
||||||
## C Extension
|
## C Extension
|
||||||
|
|
||||||
mruby can be extended with C. This is possible by using the C API to
|
mruby can be extended with C. This is possible by using the C API to
|
||||||
@@ -250,6 +267,7 @@ mrbgems expects that you have implemented a C method called
|
|||||||
`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
|
`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
|
||||||
by the name of your GEM. If you call your GEM *c_extension_example*, your
|
by the name of your GEM. If you call your GEM *c_extension_example*, your
|
||||||
initialisation method could look like this:
|
initialisation method could look like this:
|
||||||
|
|
||||||
```C
|
```C
|
||||||
void
|
void
|
||||||
mrb_c_extension_example_gem_init(mrb_state* mrb) {
|
mrb_c_extension_example_gem_init(mrb_state* mrb) {
|
||||||
@@ -294,7 +312,6 @@ mruby can be extended with pure Ruby. It is possible to override existing
|
|||||||
classes or add new ones in this way. Put all Ruby files into the *mrblib*
|
classes or add new ones in this way. Put all Ruby files into the *mrblib*
|
||||||
folder.
|
folder.
|
||||||
|
|
||||||
|
|
||||||
### Pre-Conditions
|
### Pre-Conditions
|
||||||
|
|
||||||
none
|
none
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# Symbols
|
||||||
|
|
||||||
|
Symbols in `mruby` C source code is represented by `mrb_sym` which is alias of
|
||||||
|
`uint32_t`. Lower 30 bits are used for symbols so that higher 2 bits can be
|
||||||
|
used as flags, e.g. `struct mt_elem` in `class.c`.
|
||||||
|
|
||||||
|
```C
|
||||||
|
struct mt_elem {
|
||||||
|
union mt_ptr ptr;
|
||||||
|
size_t func_p:1;
|
||||||
|
size_t noarg_p:1;
|
||||||
|
mrb_sym key:sizeof(mrb_sym)*8-2;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## C API
|
||||||
|
|
||||||
|
We provide following C API for symbols.
|
||||||
|
|
||||||
|
### Generate Symbols
|
||||||
|
|
||||||
|
#### `mrb_sym mrb_intern(mrb_state*,const char*,size_t)`
|
||||||
|
|
||||||
|
Get a symbol from a string.
|
||||||
|
|
||||||
|
#### `mrb_sym mrb_intern_check_cstr(mrb_state*,const char*)`
|
||||||
|
|
||||||
|
Get a symbol from a NULL terminated (C) string.
|
||||||
|
|
||||||
|
#### `mrb_sym mrb_intern_str(mrb_state*,mrb_value)`
|
||||||
|
|
||||||
|
Get a symbol from a Ruby string object.
|
||||||
|
|
||||||
|
#### `mrb_intern_lit(mrb_state*,const char*)`
|
||||||
|
|
||||||
|
Get a symbol from a C string literal. The second argument should be a C string
|
||||||
|
literal, otherwise you will get a compilation error. It does not copy C string
|
||||||
|
given the fact it's a literal.
|
||||||
|
|
||||||
|
#### `mrb_sym mrb_intern_check(mrb_state*,const char*,size_t)`
|
||||||
|
|
||||||
|
Get a symbol from a string if the string has been already registered as a
|
||||||
|
symbol, otherwise return `0`. We also provide variants `mrb_intern_check_str()`
|
||||||
|
(from Ruby string) and `mrb_intern_check_cstr()` (from C string).
|
||||||
|
|
||||||
|
#### `const char *mrb_sym_name(mrb_state*,mrb_sym)`
|
||||||
|
|
||||||
|
Get a string representation of a symbol as a C string.
|
||||||
|
|
||||||
|
#### `const char *mrb_sym_name_len(mrb_state*,mrb_sym,mrb_int*)`
|
||||||
|
|
||||||
|
Get a string representation of a symbol, and its length.
|
||||||
|
|
||||||
|
## Preallocate Symbols
|
||||||
|
|
||||||
|
To save RAM, `mruby` can use compile-time allocation of some symbols. You can
|
||||||
|
use following macros to get preallocated symbols by including `mruby/presym.h`
|
||||||
|
header.
|
||||||
|
|
||||||
|
* `MRB_SYM(xor)` //=> xor (Word characters)
|
||||||
|
* `MRB_SYM_B(xor)` //=> xor! (Method with Bang)
|
||||||
|
* `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark)
|
||||||
|
* `MRB_SYM_E(xor)` //=> xor= (Method with Equal)
|
||||||
|
* `MRB_CVSYM(xor)` //=> @@xor (Class Variable)
|
||||||
|
* `MRB_IVSYM(xor)` //=> @xor (Instance Variable)
|
||||||
|
* `MRB_OPSYM(xor)` //=> ^ (Operator)
|
||||||
|
|
||||||
|
For `MRB_OPSYM()`, specify the names corresponding to operators (see
|
||||||
|
`MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that
|
||||||
|
can be specified for it). Other than that, describe only word characters
|
||||||
|
excluding leading and ending punctuations.
|
||||||
|
|
||||||
|
These macros are converted to static symbol IDs at compile time, unless
|
||||||
|
preallocate symbols are disabled by `conf.disable_presym`. In that case,
|
||||||
|
these macros are expanded to `mrb_intern_lit` calls, therefore the mruby state
|
||||||
|
variable is required. The above macros assume the variable name is `mrb`. If
|
||||||
|
its name is not `mrb`, you need to use macros with `_2` suffix, such as
|
||||||
|
`MRB_SYM_2` to specify `mrb_state*` variable.
|
||||||
|
|
||||||
|
### Disabling Preallocated Symbols
|
||||||
|
|
||||||
|
You can disable preallocated symbols by specifying `conf.disable_presym` in the
|
||||||
|
configuration file.
|
||||||
+41
-42
@@ -13,15 +13,6 @@ This document is collecting these limitations.
|
|||||||
This document does not contain a complete list of limitations.
|
This document does not contain a complete list of limitations.
|
||||||
Please help to improve it by submitting your findings.
|
Please help to improve it by submitting your findings.
|
||||||
|
|
||||||
|
|
||||||
## `1/2` gives `0.5`
|
|
||||||
|
|
||||||
Since mruby does not have `Bignum`, bigger integers are represented
|
|
||||||
by `Float` numbers. To enhance interoperability between `Fixnum`
|
|
||||||
and `Float`, mruby provides `Float#upto` and other iterating
|
|
||||||
methods for the `Float` class. As a side effect, `1/2` gives `0.5`
|
|
||||||
not `0`.
|
|
||||||
|
|
||||||
## `Array` passed to `puts`
|
## `Array` passed to `puts`
|
||||||
|
|
||||||
Passing an Array to `puts` results in different output.
|
Passing an Array to `puts` results in different output.
|
||||||
@@ -38,7 +29,7 @@ puts [1,2,3]
|
|||||||
3
|
3
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
```
|
```
|
||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
@@ -61,9 +52,17 @@ end
|
|||||||
|
|
||||||
`ZeroDivisionError` is raised.
|
`ZeroDivisionError` is raised.
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
No exception is raised.
|
No exception is raised. Instead you have to do:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
begin
|
||||||
|
1 / 0
|
||||||
|
rescue => e
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Fiber execution can't cross C function boundary
|
## Fiber execution can't cross C function boundary
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ p Liste.new "foobar"
|
|||||||
|
|
||||||
` [] `
|
` [] `
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
`ArgumentError` is raised.
|
`ArgumentError` is raised.
|
||||||
|
|
||||||
@@ -119,7 +118,7 @@ false
|
|||||||
true
|
true
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
```
|
```
|
||||||
true
|
true
|
||||||
@@ -156,7 +155,7 @@ p 'ok'
|
|||||||
ok
|
ok
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
```
|
```
|
||||||
test.rb:8: undefined method 'test_func' (NoMethodError)
|
test.rb:8: undefined method 'test_func' (NoMethodError)
|
||||||
@@ -178,7 +177,7 @@ defined?(Foo)
|
|||||||
nil
|
nil
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
`NameError` is raised.
|
`NameError` is raised.
|
||||||
|
|
||||||
@@ -195,7 +194,7 @@ alias $a $__a__
|
|||||||
|
|
||||||
` nil `
|
` nil `
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
Syntax error
|
Syntax error
|
||||||
|
|
||||||
@@ -217,7 +216,7 @@ end
|
|||||||
`ArgumentError` is raised.
|
`ArgumentError` is raised.
|
||||||
The re-defined `+` operator does not accept any arguments.
|
The re-defined `+` operator does not accept any arguments.
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
` 'ab' `
|
` 'ab' `
|
||||||
Behavior of the operator wasn't changed.
|
Behavior of the operator wasn't changed.
|
||||||
@@ -233,7 +232,7 @@ $ ruby -e 'puts Proc.new {}.binding'
|
|||||||
#<Binding:0x00000e9deabb9950>
|
#<Binding:0x00000e9deabb9950>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [2.1.2 (2020-08-06)]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./bin/mruby -e 'puts Proc.new {}.binding'
|
$ ./bin/mruby -e 'puts Proc.new {}.binding'
|
||||||
@@ -245,8 +244,7 @@ trace (most recent call last):
|
|||||||
## Keyword arguments
|
## Keyword arguments
|
||||||
|
|
||||||
mruby keyword arguments behave slightly different from CRuby 2.5
|
mruby keyword arguments behave slightly different from CRuby 2.5
|
||||||
to make the behavior simpler and less confusing. Maybe in the
|
to make the behavior simpler and less confusing.
|
||||||
future, the simpler behavior will be adopted to CRuby as well.
|
|
||||||
|
|
||||||
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
|
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
|
||||||
|
|
||||||
@@ -255,7 +253,7 @@ $ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
|
|||||||
[[{"a"=>1}], {:b=>2}]
|
[[{"a"=>1}], {:b=>2}]
|
||||||
```
|
```
|
||||||
|
|
||||||
#### mruby [mruby 2.1.2]
|
#### mruby [3.0.0 (2021-03-05)]
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
|
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
|
||||||
@@ -264,26 +262,6 @@ trace (most recent call last):
|
|||||||
-e:1: keyword argument hash with non symbol keys (ArgumentError)
|
-e:1: keyword argument hash with non symbol keys (ArgumentError)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Argument Destructuring
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
def m(a,(b,c),d); p [a,b,c,d]; end
|
|
||||||
m(1,[2,3],4) # => [1,2,3,4]
|
|
||||||
```
|
|
||||||
Destructured arguments (`b` and `c` in above example) cannot be accessed
|
|
||||||
from the default expression of optional arguments and keyword arguments,
|
|
||||||
since actual assignment is done after the evaluation of those default
|
|
||||||
expressions. Thus:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
def f(a,(b,c),d=b)
|
|
||||||
p [a,b,c,d]
|
|
||||||
end
|
|
||||||
f(1,[2,3])
|
|
||||||
```
|
|
||||||
|
|
||||||
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
|
|
||||||
|
|
||||||
## `nil?` redefinition in conditional expressions
|
## `nil?` redefinition in conditional expressions
|
||||||
|
|
||||||
Redefinition of `nil?` is ignored in conditional expressions.
|
Redefinition of `nil?` is ignored in conditional expressions.
|
||||||
@@ -297,3 +275,24 @@ puts(a.nil? ? "truthy" : "falsy")
|
|||||||
```
|
```
|
||||||
|
|
||||||
Ruby outputs `falsy`. mruby outputs `truthy`.
|
Ruby outputs `falsy`. mruby outputs `truthy`.
|
||||||
|
|
||||||
|
## Argument Destructuring
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
def m(a,(b,c),d); p [a,b,c,d]; end
|
||||||
|
m(1,[2,3],4) # => [1,2,3,4]
|
||||||
|
```
|
||||||
|
|
||||||
|
Destructured arguments (`b` and `c` in above example) cannot be accessed
|
||||||
|
from the default expression of optional arguments and keyword arguments,
|
||||||
|
since actual assignment is done after the evaluation of those default
|
||||||
|
expressions. Thus:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
def f(a,(b,c),d=b)
|
||||||
|
p [a,b,c,d]
|
||||||
|
end
|
||||||
|
f(1,[2,3])
|
||||||
|
```
|
||||||
|
|
||||||
|
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
|
||||||
|
|||||||
+163
@@ -0,0 +1,163 @@
|
|||||||
|
User visible changes in `mruby3`
|
||||||
|
===
|
||||||
|
|
||||||
|
# Build System
|
||||||
|
|
||||||
|
## `build_config` directory
|
||||||
|
|
||||||
|
Typical build configuration files are located in `build_config`
|
||||||
|
directory. For examples:
|
||||||
|
|
||||||
|
* `default`: the default configuration
|
||||||
|
* `host-gprof`: compiles with `gprof` for performance tuning
|
||||||
|
* `host-m32`: compiles in gcc 32bit mode on 64bit platforms
|
||||||
|
* `boxing`: compiles all three boxing options
|
||||||
|
* `clang-asan`: compiles with `clang`'s Address Sanitizer
|
||||||
|
|
||||||
|
You can specify the build configuration file with the
|
||||||
|
`MRUBY_CONFIG` environment variable (or `CONFIG` in short).
|
||||||
|
If the value specified by `MRUBY_CONFIG` is not the path to
|
||||||
|
the configuration file, `build_config/${MRUBY_CONFIG}.rb` is
|
||||||
|
used. So you can specify it as `rake MRUBY_CONFIG=boxing`,
|
||||||
|
for example.
|
||||||
|
|
||||||
|
# Build Configuration Contribution
|
||||||
|
|
||||||
|
When you write a new build configuration description, please
|
||||||
|
contribute. We welcome your contribution as a GitHub
|
||||||
|
pull-request.
|
||||||
|
|
||||||
|
# Language Changes
|
||||||
|
|
||||||
|
## New Syntax
|
||||||
|
|
||||||
|
We have ported some new syntax from CRuby.
|
||||||
|
|
||||||
|
* Single line pattern matching (`12 => x`);
|
||||||
|
mruby matches only with local variables at the moment
|
||||||
|
* Numbered block parameter (`x.map{_1 * 2}`)
|
||||||
|
* End-less `def` (`def double(x) = x*2`)
|
||||||
|
|
||||||
|
# Configuration Options Changed
|
||||||
|
|
||||||
|
## Renamed for consistency
|
||||||
|
|
||||||
|
Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
|
||||||
|
or `MRB_NO_XXX`).
|
||||||
|
|
||||||
|
| mruby2 | mruby3 |
|
||||||
|
|--------------------------------|---------------------------|
|
||||||
|
| `MRB_ENABLE_ALL_SYMBOLS` | `MRB_USE_ALL_SYMBOLS` |
|
||||||
|
| `MRB_ENABLE_CXX_ABI` | `MRB_USE_CXX_ABI` |
|
||||||
|
| `MRB_ENABLE_CXX_EXCEPTION` | `MRB_USE_CXX_EXCEPTION` |
|
||||||
|
| `MRB_ENABLE_DEBUG_HOOK` | `MRB_USE_DEBUG_HOOK` |
|
||||||
|
| `MRB_DISABLE_DIRECT_THREADING` | `MRB_NO_DIRECT_THREADING` |
|
||||||
|
| `MRB_DISABLE_STDIO` | `MRB_NO_STDIO` |
|
||||||
|
| `MRB_METHOD_T_STRUCT` | `MRB_USE_METHOD_T_STRUCT` |
|
||||||
|
| `MRB_USE_FLOAT` | `MRB_USE_FLOAT32` |
|
||||||
|
| `MRB_WITHOUT_FLOAT` | `MRB_NO_FLOAT` |
|
||||||
|
| `ENABLE_LINENOISE` | `MRB_USE_LINENOISE` |
|
||||||
|
| `ENABLE_READLINE` | `MRB_USE_READLINE` |
|
||||||
|
| `DISABLE_MIRB_UNDERSCORE` | `MRB_NO_MIRB_UNDERSCORE` |
|
||||||
|
|
||||||
|
* `MRB_USE_FLOAT32` is changed from `MRB_USE_FLOAT` to make sure `float` here
|
||||||
|
means using single precision float, and not the opposite of `MRB_NO_FLOAT`.
|
||||||
|
* `MRB_USE_METHOD_T_STRUCT` uses `struct` version of `mrb_method_t`. More
|
||||||
|
portable but consumes more memory. Turned on by default on 32bit platforms.
|
||||||
|
* `MRB_` prefix is added to those without.
|
||||||
|
|
||||||
|
## `MRB_NO_BOXING`
|
||||||
|
|
||||||
|
Uses `struct` to represent `mrb_value`. Consumes more memory
|
||||||
|
but easier to investigate the internal and to debug. It used
|
||||||
|
to be default `mrb_value` representation. Now the default is
|
||||||
|
`MRB_WORD_BOXING`.
|
||||||
|
|
||||||
|
## `MRB_WORD_BOXING`
|
||||||
|
|
||||||
|
Pack `mrb_value` in an `intptr_t` integer. Consumes less
|
||||||
|
memory compared to `MRB_NO_BOXING` especially on 32 bit
|
||||||
|
platforms. `Fixnum` size is 31 bits so some integer values
|
||||||
|
does not fit in `Fixnum` integers.
|
||||||
|
|
||||||
|
## `MRB_NAN_BOXING`
|
||||||
|
|
||||||
|
Pack `mrb_value` in a floating pointer number. Nothing
|
||||||
|
changed from previous versions.
|
||||||
|
|
||||||
|
## `MRB_USE_MALLOC_TRIM`
|
||||||
|
|
||||||
|
Call `malloc_trim(0)` from mrb_full_gc() if this macro is defined.
|
||||||
|
If you are using glibc malloc, this macro could reduce memory consumption.
|
||||||
|
|
||||||
|
# Command Line Program
|
||||||
|
|
||||||
|
## `bin/mruby` (by mrbgems/mruby-bin-mruby)
|
||||||
|
|
||||||
|
The mruby3 now automatically detects `*.mrb` files without the `-b`
|
||||||
|
switch. Therefore, it can be mixed with the `*.rb` file in combination
|
||||||
|
with the `-r` switch and specified at the same time.
|
||||||
|
Here's an example that works fine:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ bin/mruby app.mrb
|
||||||
|
$ bin/mruby -r lib1.mrb -r lib2.rb app.rb
|
||||||
|
$ bin/mruby -r lib1.rb -r lib2.rb < app.mrb
|
||||||
|
```
|
||||||
|
|
||||||
|
# Internal Changes
|
||||||
|
|
||||||
|
## New Instructions
|
||||||
|
|
||||||
|
`mruby3` introduces a few new instructions.
|
||||||
|
|
||||||
|
Instructions that access pool[i]/syms[i] where i>255.
|
||||||
|
|
||||||
|
* `OP_LOADL16`
|
||||||
|
* `OP_STRING16`
|
||||||
|
* `OP_LOADSYM16`
|
||||||
|
|
||||||
|
Instructions that load a 32 bit integer.
|
||||||
|
|
||||||
|
* `OP_LOADI32`
|
||||||
|
|
||||||
|
Instruction that unwinds jump table for rescue/ensure.
|
||||||
|
|
||||||
|
* `OP_JMPUW`
|
||||||
|
|
||||||
|
Renamed from `OP_RAISE`
|
||||||
|
|
||||||
|
* `OP_RAISEIF`
|
||||||
|
|
||||||
|
Instruction that is reserved for the future keyword argument support.
|
||||||
|
|
||||||
|
* OP_SENDVK
|
||||||
|
|
||||||
|
## Removed Instructions
|
||||||
|
|
||||||
|
Instructions for old exception handling
|
||||||
|
|
||||||
|
* `OP_ONERR`
|
||||||
|
* `OP_POPERR`
|
||||||
|
* `OP_EPUSH`
|
||||||
|
* `OP_EPOP`
|
||||||
|
|
||||||
|
No more operand extension
|
||||||
|
|
||||||
|
* `OP_EXT1`
|
||||||
|
* `OP_EXT2`
|
||||||
|
* `OP_EXT3`
|
||||||
|
|
||||||
|
## Changed Instructions
|
||||||
|
|
||||||
|
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the address of the next instruction.
|
||||||
|
|
||||||
|
## `Random` now use `xoshiro128++`.
|
||||||
|
|
||||||
|
For better and faster random number generation.
|
||||||
|
|
||||||
|
## Preallocated Symbol
|
||||||
|
|
||||||
|
Preallocated symbols are interned at compile-time. They can be accessed via symbols macros (e.g. `MRB_SYM()`).
|
||||||
|
|
||||||
|
See [Symbols](https://github.com/mruby/mruby/blob/master/doc/guides/symbol.md).
|
||||||
+93
-107
@@ -20,121 +20,107 @@ sign) of operands.
|
|||||||
* sS: signed 16bit
|
* sS: signed 16bit
|
||||||
* W: 24bit
|
* W: 24bit
|
||||||
|
|
||||||
First two byte operands may be extended to 16bit. When those byte
|
|
||||||
operands are bigger than 256, the instruction will be prefixed by
|
|
||||||
`OP_EXT1` (means 1st operand is 16bit) or `OP_EXT2` (means 2nd operand
|
|
||||||
is 16bit) or `OP_EXT3` (means 1st and 2nd operands are 16bit).
|
|
||||||
|
|
||||||
For instructions marked by `'`, `OP_EXT1` can be prefixed. For those
|
|
||||||
with `"`, either `OP_EXT1` or `OP_EXT2` or `OP_EXT2` can be prefixed.
|
|
||||||
|
|
||||||
## table.1 Instruction Table
|
## table.1 Instruction Table
|
||||||
|
|
||||||
| Instruction Name | Operand type | Semantics |
|
| Instruction Name | Operand type | Semantics |
|
||||||
|------------------|--------------|--------------------------------------------------------|
|
|------------------|--------------|--------------------------------------------------------|
|
||||||
| OP_NOP | - | no operation |
|
| OP_NOP | - | no operation |
|
||||||
| OP_MOVE" | BB | R(a) = R(b) |
|
| OP_MOVE | BB | R(a) = R(b) |
|
||||||
| OP_LOADL" | BB | R(a) = Pool(b) |
|
| OP_LOADL | BB | R(a) = Pool(b) |
|
||||||
| OP_LOADI" | BB | R(a) = mrb_int(b) |
|
| OP_LOADI | BB | R(a) = mrb_int(b) |
|
||||||
| OP_LOADINEG" | BB | R(a) = mrb_int(-b) |
|
| OP_LOADINEG | BB | R(a) = mrb_int(-b) |
|
||||||
| OP_LOADI__1' | B | R(a) = mrb_int(-1) |
|
| OP_LOADI__1 | B | R(a) = mrb_int(-1) |
|
||||||
| OP_LOADI_0' | B | R(a) = mrb_int(0) |
|
| OP_LOADI_0 | B | R(a) = mrb_int(0) |
|
||||||
| OP_LOADI_1' | B | R(a) = mrb_int(1) |
|
| OP_LOADI_1 | B | R(a) = mrb_int(1) |
|
||||||
| OP_LOADI_2' | B | R(a) = mrb_int(2) |
|
| OP_LOADI_2 | B | R(a) = mrb_int(2) |
|
||||||
| OP_LOADI_3' | B | R(a) = mrb_int(3) |
|
| OP_LOADI_3 | B | R(a) = mrb_int(3) |
|
||||||
| OP_LOADI_4' | B | R(a) = mrb_int(4) |
|
| OP_LOADI_4 | B | R(a) = mrb_int(4) |
|
||||||
| OP_LOADI_5' | B | R(a) = mrb_int(5) |
|
| OP_LOADI_5 | B | R(a) = mrb_int(5) |
|
||||||
| OP_LOADI_6' | B | R(a) = mrb_int(6) |
|
| OP_LOADI_6 | B | R(a) = mrb_int(6) |
|
||||||
| OP_LOADI_7' | B | R(a) = mrb_int(7) |
|
| OP_LOADI_7 | B | R(a) = mrb_int(7) |
|
||||||
| OP_LOADI16' | BsS | R(a) = mrb_int(b) |
|
| OP_LOADI16 | BsS | R(a) = mrb_int(b) |
|
||||||
| OP_LOADSYM" | BB | R(a) = Syms(b) |
|
| OP_LOADSYM | BB | R(a) = Syms(b) |
|
||||||
| OP_LOADNIL' | B | R(a) = nil |
|
| OP_LOADNIL | B | R(a) = nil |
|
||||||
| OP_LOADSELF' | B | R(a) = self |
|
| OP_LOADSELF | B | R(a) = self |
|
||||||
| OP_LOADT' | B | R(a) = true |
|
| OP_LOADT | B | R(a) = true |
|
||||||
| OP_LOADF' | B | R(a) = false |
|
| OP_LOADF | B | R(a) = false |
|
||||||
| OP_GETGV" | BB | R(a) = getglobal(Syms(b)) |
|
| OP_GETGV | BB | R(a) = getglobal(Syms(b)) |
|
||||||
| OP_SETGV" | BB | setglobal(Syms(b), R(a)) |
|
| OP_SETGV | BB | setglobal(Syms(b), R(a)) |
|
||||||
| OP_GETSV" | BB | R(a) = Special[Syms(b)] |
|
| OP_GETSV | BB | R(a) = Special[Syms(b)] |
|
||||||
| OP_SETSV" | BB | Special[Syms(b)] = R(a) |
|
| OP_SETSV | BB | Special[Syms(b)] = R(a) |
|
||||||
| OP_GETIV" | BB | R(a) = ivget(Syms(b)) |
|
| OP_GETIV | BB | R(a) = ivget(Syms(b)) |
|
||||||
| OP_SETIV" | BB | ivset(Syms(b),R(a)) |
|
| OP_SETIV | BB | ivset(Syms(b),R(a)) |
|
||||||
| OP_GETCV" | BB | R(a) = cvget(Syms(b)) |
|
| OP_GETCV | BB | R(a) = cvget(Syms(b)) |
|
||||||
| OP_SETCV" | BB | cvset(Syms(b),R(a)) |
|
| OP_SETCV | BB | cvset(Syms(b),R(a)) |
|
||||||
| OP_GETCONST" | BB | R(a) = constget(Syms(b)) |
|
| OP_GETCONST | BB | R(a) = constget(Syms(b)) |
|
||||||
| OP_SETCONST" | BB | constset(Syms(b),R(a)) |
|
| OP_SETCONST | BB | constset(Syms(b),R(a)) |
|
||||||
| OP_GETMCNST" | BB | R(a) = R(a)::Syms(b) |
|
| OP_GETMCNST | BB | R(a) = R(a)::Syms(b) |
|
||||||
| OP_SETMCNST" | BB | R(a+1)::Syms(b) = R(a) |
|
| OP_SETMCNST | BB | R(a+1)::Syms(b) = R(a) |
|
||||||
| OP_GETUPVAR" | BBB | R(a) = uvget(b,c) |
|
| OP_GETUPVAR | BBB | R(a) = uvget(b,c) |
|
||||||
| OP_SETUPVAR" | BBB | uvset(b,c,R(a)) |
|
| OP_SETUPVAR | BBB | uvset(b,c,R(a)) |
|
||||||
| OP_JMP | S | pc=a |
|
| OP_JMP | S | pc=a |
|
||||||
| OP_JMPIF' | BS | if R(a) pc=b |
|
| OP_JMPIF | BS | if R(a) pc=b |
|
||||||
| OP_JMPNOT' | BS | if !R(a) pc=b |
|
| OP_JMPNOT | BS | if !R(a) pc=b |
|
||||||
| OP_JMPNIL' | BS | if R(a)==nil pc=b |
|
| OP_JMPNIL | BS | if R(a)==nil pc=b |
|
||||||
| OP_ONERR | S | rescue_push(a) |
|
| OP_JMPUW | S | unwind_and_jump_to(a) |
|
||||||
| OP_EXCEPT' | B | R(a) = exc |
|
| OP_EXCEPT | B | R(a) = exc |
|
||||||
| OP_RESCUE" | BB | R(b) = R(a).isa?(R(b)) |
|
| OP_RESCUE | BB | R(b) = R(a).isa?(R(b)) |
|
||||||
| OP_POPERR' | B | a.times{rescue_pop()} |
|
| OP_RAISEIF | B | raise(R(a)) if R(a) |
|
||||||
| OP_RAISE' | B | raise(R(a)) |
|
| OP_SENDV | BB | R(a) = call(R(a),Syms(b),*R(a+1)) |
|
||||||
| OP_EPUSH' | B | ensure_push(SEQ[a]) |
|
| OP_SENDVB | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) |
|
||||||
| OP_EPOP' | B | A.times{ensure_pop().call} |
|
| OP_SEND | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) |
|
||||||
| OP_SENDV" | BB | R(a) = call(R(a),Syms(b),*R(a+1)) |
|
| OP_SENDB | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) |
|
||||||
| OP_SENDVB" | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) |
|
|
||||||
| OP_SEND" | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) |
|
|
||||||
| OP_SENDB" | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) |
|
|
||||||
| OP_CALL | - | R(0) = self.call(frame.argc, frame.argv) |
|
| OP_CALL | - | R(0) = self.call(frame.argc, frame.argv) |
|
||||||
| OP_SUPER" | BB | R(a) = super(R(a+1),... ,R(a+b+1)) |
|
| OP_SUPER | BB | R(a) = super(R(a+1),... ,R(a+b+1)) |
|
||||||
| OP_ARGARY' | BS | R(a) = argument array (16=5:1:5:1:4) |
|
| OP_ARGARY | BS | R(a) = argument array (16=5:1:5:1:4) |
|
||||||
| OP_ENTER | W | arg setup according to flags (23=5:5:1:5:5:1:1) |
|
| OP_ENTER | W | arg setup according to flags (23=5:5:1:5:5:1:1) |
|
||||||
| OP_KEY_P" | BB | R(a) = kdict.key?(Syms(b)) |
|
| OP_KEY_P | BB | R(a) = kdict.key?(Syms(b)) |
|
||||||
| OP_KEYEND | - | raise unless kdict.empty? |
|
| OP_KEYEND | - | raise unless kdict.empty? |
|
||||||
| OP_KARG" | BB | R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) |
|
| OP_KARG | BB | R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) |
|
||||||
| OP_RETURN' | B | return R(a) (normal) |
|
| OP_RETURN | B | return R(a) (normal) |
|
||||||
| OP_RETURN_BLK' | B | return R(a) (in-block return) |
|
| OP_RETURN_BLK | B | return R(a) (in-block return) |
|
||||||
| OP_BREAK' | B | break R(a) |
|
| OP_BREAK | B | break R(a) |
|
||||||
| OP_BLKPUSH' | BS | R(a) = block (16=5:1:5:1:4) |
|
| OP_BLKPUSH | BS | R(a) = block (16=5:1:5:1:4) |
|
||||||
| OP_ADD' | B | R(a) = R(a)+R(a+1) |
|
| OP_ADD | B | R(a) = R(a)+R(a+1) |
|
||||||
| OP_ADDI" | BB | R(a) = R(a)+mrb_int(b) |
|
| OP_ADDI | BB | R(a) = R(a)+mrb_int(b) |
|
||||||
| OP_SUB' | B | R(a) = R(a)-R(a+1) |
|
| OP_SUB | B | R(a) = R(a)-R(a+1) |
|
||||||
| OP_SUBI" | BB | R(a) = R(a)-mrb_int(b) |
|
| OP_SUBI | BB | R(a) = R(a)-mrb_int(b) |
|
||||||
| OP_MUL' | B | R(a) = R(a)*R(a+1) |
|
| OP_MUL | B | R(a) = R(a)*R(a+1) |
|
||||||
| OP_DIV' | B | R(a) = R(a)/R(a+1) |
|
| OP_DIV | B | R(a) = R(a)/R(a+1) |
|
||||||
| OP_EQ' | B | R(a) = R(a)==R(a+1) |
|
| OP_EQ | B | R(a) = R(a)==R(a+1) |
|
||||||
| OP_LT' | B | R(a) = R(a)<R(a+1) |
|
| OP_LT | B | R(a) = R(a)<R(a+1) |
|
||||||
| OP_LE' | B | R(a) = R(a)<=R(a+1) |
|
| OP_LE | B | R(a) = R(a)<=R(a+1) |
|
||||||
| OP_GT' | B | R(a) = R(a)>R(a+1) |
|
| OP_GT | B | R(a) = R(a)>R(a+1) |
|
||||||
| OP_GE' | B | R(a) = R(a)>=R(a+1) |
|
| OP_GE | B | R(a) = R(a)>=R(a+1) |
|
||||||
| OP_ARRAY" | BB | R(a) = ary_new(R(a),R(a+1)..R(a+b)) |
|
| OP_ARRAY | BB | R(a) = ary_new(R(a),R(a+1)..R(a+b)) |
|
||||||
| OP_ARRAY2" | BBB | R(a) = ary_new(R(b),R(b+1)..R(b+c)) |
|
| OP_ARRAY2 | BBB | R(a) = ary_new(R(b),R(b+1)..R(b+c)) |
|
||||||
| OP_ARYCAT' | B | ary_cat(R(a),R(a+1)) |
|
| OP_ARYCAT | B | ary_cat(R(a),R(a+1)) |
|
||||||
| OP_ARYPUSH' | B | ary_push(R(a),R(a+1)) |
|
| OP_ARYPUSH | B | ary_push(R(a),R(a+1)) |
|
||||||
| OP_ARYDUP' | B | R(a) = ary_dup(R(a)) |
|
| OP_ARYDUP | B | R(a) = ary_dup(R(a)) |
|
||||||
| OP_AREF" | BBB | R(a) = R(b)[c] |
|
| OP_AREF | BBB | R(a) = R(b)[c] |
|
||||||
| OP_ASET" | BBB | R(a)[c] = R(b) |
|
| OP_ASET | BBB | R(a)[c] = R(b) |
|
||||||
| OP_APOST" | BBB | *R(a),R(a+1)..R(a+c) = R(a)[b..] |
|
| OP_APOST | BBB | *R(a),R(a+1)..R(a+c) = R(a)[b..] |
|
||||||
| OP_INTERN' | B | R(a) = intern(R(a)) |
|
| OP_INTERN | B | R(a) = intern(R(a)) |
|
||||||
| OP_STRING" | BB | R(a) = str_dup(Lit(b)) |
|
| OP_STRING | BB | R(a) = str_dup(Lit(b)) |
|
||||||
| OP_STRCAT' | B | str_cat(R(a),R(a+1)) |
|
| OP_STRCAT | B | str_cat(R(a),R(a+1)) |
|
||||||
| OP_HASH" | BB | R(a) = hash_new(R(a),R(a+1)..R(a+b)) |
|
| OP_HASH | BB | R(a) = hash_new(R(a),R(a+1)..R(a+b)) |
|
||||||
| OP_HASHADD" | BB | R(a) = hash_push(R(a),R(a+1)..R(a+b)) |
|
| OP_HASHADD | BB | R(a) = hash_push(R(a),R(a+1)..R(a+b)) |
|
||||||
| OP_HASHCAT' | B | R(a) = hash_cat(R(a),R(a+1)) |
|
| OP_HASHCAT | B | R(a) = hash_cat(R(a),R(a+1)) |
|
||||||
| OP_LAMBDA" | BB | R(a) = lambda(SEQ[b],OP_L_LAMBDA) |
|
| OP_LAMBDA | BB | R(a) = lambda(SEQ[b],OP_L_LAMBDA) |
|
||||||
| OP_BLOCK" | BB | R(a) = lambda(SEQ[b],OP_L_BLOCK) |
|
| OP_BLOCK | BB | R(a) = lambda(SEQ[b],OP_L_BLOCK) |
|
||||||
| OP_METHOD" | BB | R(a) = lambda(SEQ[b],OP_L_METHOD) |
|
| OP_METHOD | BB | R(a) = lambda(SEQ[b],OP_L_METHOD) |
|
||||||
| OP_RANGE_INC' | B | R(a) = range_new(R(a),R(a+1),FALSE) |
|
| OP_RANGE_INC | B | R(a) = range_new(R(a),R(a+1),FALSE) |
|
||||||
| OP_RANGE_EXC' | B | R(a) = range_new(R(a),R(a+1),TRUE) |
|
| OP_RANGE_EXC | B | R(a) = range_new(R(a),R(a+1),TRUE) |
|
||||||
| OP_OCLASS' | B | R(a) = ::Object |
|
| OP_OCLASS | B | R(a) = ::Object |
|
||||||
| OP_CLASS" | BB | R(a) = newclass(R(a),Syms(b),R(a+1)) |
|
| OP_CLASS | BB | R(a) = newclass(R(a),Syms(b),R(a+1)) |
|
||||||
| OP_MODULE" | BB | R(a) = newmodule(R(a),Syms(b)) |
|
| OP_MODULE | BB | R(a) = newmodule(R(a),Syms(b)) |
|
||||||
| OP_EXEC" | BB | R(a) = blockexec(R(a),SEQ[b]) |
|
| OP_EXEC | BB | R(a) = blockexec(R(a),SEQ[b]) |
|
||||||
| OP_DEF" | BB | R(a).newmethod(Syms(b),R(a+1)) |
|
| OP_DEF | BB | R(a).newmethod(Syms(b),R(a+1)) |
|
||||||
| OP_ALIAS" | BB | alias_method(target_class,Syms(a),Syms(b)) |
|
| OP_ALIAS | BB | alias_method(target_class,Syms(a),Syms(b)) |
|
||||||
| OP_UNDEF' | B | undef_method(target_class,Syms(a)) |
|
| OP_UNDEF | B | undef_method(target_class,Syms(a)) |
|
||||||
| OP_SCLASS' | B | R(a) = R(a).singleton_class |
|
| OP_SCLASS | B | R(a) = R(a).singleton_class |
|
||||||
| OP_TCLASS' | B | R(a) = target_class |
|
| OP_TCLASS | B | R(a) = target_class |
|
||||||
| OP_DEBUG" | BBB | print a,b,c |
|
| OP_DEBUG | BBB | print a,b,c |
|
||||||
| OP_ERR' | B | raise(LocalJumpError, Lit(a)) |
|
| OP_ERR | B | raise(LocalJumpError, Lit(a)) |
|
||||||
| OP_EXT1 | - | make 1st operand 16bit |
|
|
||||||
| OP_EXT2 | - | make 2nd operand 16bit |
|
|
||||||
| OP_EXT3 | - | make 1st and 2nd operands 16bit |
|
|
||||||
| OP_STOP | - | stop VM |
|
| OP_STOP | - | stop VM |
|
||||||
|------------------|--------------|--------------------------------------------------------|
|
|------------------|--------------|--------------------------------------------------------|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module CRubyExtension
|
module CRubyExtension
|
||||||
def CRubyExtension.ruby_method
|
def CRubyExtension.ruby_method
|
||||||
puts "A Ruby Extension"
|
puts "#{self}: A Ruby Extension"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#include <mruby.h>
|
#include <mruby.h>
|
||||||
|
#include <mruby/string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static mrb_value
|
static mrb_value
|
||||||
mrb_c_method(mrb_state *mrb, mrb_value self)
|
mrb_c_method(mrb_state *mrb, mrb_value self)
|
||||||
{
|
{
|
||||||
puts("A C Extension");
|
mrb_value self_str = mrb_str_to_str(mrb, self);
|
||||||
|
|
||||||
|
printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self_str));
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#include <mruby.h>
|
#include <mruby.h>
|
||||||
|
#include <mruby/string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static mrb_value
|
static mrb_value
|
||||||
mrb_c_method(mrb_state *mrb, mrb_value self)
|
mrb_c_method(mrb_state *mrb, mrb_value self)
|
||||||
{
|
{
|
||||||
puts("A C Extension");
|
mrb_value self_str = mrb_str_to_str(mrb, self);
|
||||||
|
|
||||||
|
printf("%s: A C Extension\n", mrb_str_to_cstr(mrb, self_str));
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class RubyExtension
|
class RubyExtension
|
||||||
def RubyExtension.ruby_method
|
def RubyExtension.ruby_method
|
||||||
puts "A Ruby Extension"
|
puts "#{self}: A Ruby Extension"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Requires Android NDK r13 or later.
|
|
||||||
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
|
|
||||||
params = {
|
|
||||||
:arch => 'arm64-v8a',
|
|
||||||
:platform => 'android-24',
|
|
||||||
:toolchain => :clang,
|
|
||||||
}
|
|
||||||
toolchain :android, params
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
MRuby::Build.new do |conf|
|
|
||||||
|
|
||||||
# Gets set by the VS command prompts.
|
|
||||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
|
||||||
toolchain :visualcpp
|
|
||||||
else
|
|
||||||
toolchain :gcc
|
|
||||||
end
|
|
||||||
|
|
||||||
enable_debug
|
|
||||||
|
|
||||||
# include the default GEMs
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Requires Android NDK r13 or later.
|
|
||||||
MRuby::CrossBuild.new('android-armeabi') do |conf|
|
|
||||||
params = {
|
|
||||||
:arch => 'armeabi',
|
|
||||||
:platform => 'android-24',
|
|
||||||
:toolchain => :clang,
|
|
||||||
}
|
|
||||||
toolchain :android, params
|
|
||||||
|
|
||||||
conf.gembox 'default'
|
|
||||||
end
|
|
||||||
+82
-63
@@ -25,33 +25,69 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* configuration options: */
|
/* configuration options: */
|
||||||
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
|
/* add -DMRB_USE_FLOAT32 to use float instead of double for floating point numbers */
|
||||||
//#define MRB_USE_FLOAT
|
//#define MRB_USE_FLOAT32
|
||||||
|
|
||||||
/* exclude floating point numbers */
|
/* exclude floating point numbers */
|
||||||
//#define MRB_WITHOUT_FLOAT
|
//#define MRB_NO_FLOAT
|
||||||
|
|
||||||
/* add -DMRB_METHOD_CACHE to use method cache to improve performance */
|
/* obsolete configuration */
|
||||||
//#define MRB_METHOD_CACHE
|
#if defined(MRB_USE_FLOAT)
|
||||||
|
# define MRB_USE_FLOAT32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* obsolete configuration */
|
||||||
|
#if defined(MRB_WITHOUT_FLOAT)
|
||||||
|
# define MRB_NO_FLOAT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MRB_USE_FLOAT32) && defined(MRB_NO_FLOAT)
|
||||||
|
#error Cannot define MRB_USE_FLOAT32 and MRB_NO_FLOAT at the same time
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* add -DMRB_NO_METHOD_CACHE to disable method cache to save memory */
|
||||||
|
//#define MRB_NO_METHOD_CACHE
|
||||||
/* size of the method cache (need to be the power of 2) */
|
/* size of the method cache (need to be the power of 2) */
|
||||||
//#define MRB_METHOD_CACHE_SIZE (1<<7)
|
//#define MRB_METHOD_CACHE_SIZE (1<<8)
|
||||||
|
|
||||||
/* add -DMRB_METHOD_T_STRUCT on machines that use higher bits of pointers */
|
/* add -DMRB_USE_METHOD_T_STRUCT on machines that use higher bits of function pointers */
|
||||||
/* no MRB_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */
|
/* no MRB_USE_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */
|
||||||
#ifndef MRB_METHOD_T_STRUCT
|
#ifndef MRB_USE_METHOD_T_STRUCT
|
||||||
// can't use highest 2 bits of function pointers at least on 32bit
|
// can't use highest 2 bits of function pointers at least on 32bit
|
||||||
// Windows and 32bit Linux.
|
// Windows and 32bit Linux.
|
||||||
# ifdef MRB_32BIT
|
# ifdef MRB_32BIT
|
||||||
# define MRB_METHOD_T_STRUCT
|
# define MRB_USE_METHOD_T_STRUCT
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
|
||||||
|
#ifndef MRB_ENDIAN_BIG
|
||||||
|
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
|
||||||
|
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||||
|
# define MRB_ENDIAN_BIG
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT32 and MRB_NO_FLOAT */
|
||||||
|
//#define MRB_NAN_BOXING
|
||||||
|
|
||||||
|
/* represent mrb_value as a word (natural unit of data for the processor) */
|
||||||
|
//#define MRB_WORD_BOXING
|
||||||
|
|
||||||
|
/* represent mrb_value as a struct; occupies 2 words */
|
||||||
|
//#define MRB_NO_BOXING
|
||||||
|
|
||||||
|
/* if no specific boxing type is chosen */
|
||||||
|
#if !defined(MRB_NAN_BOXING) && !defined(MRB_WORD_BOXING) && !defined(MRB_NO_BOXING)
|
||||||
|
# define MRB_WORD_BOXING
|
||||||
|
#endif
|
||||||
|
|
||||||
/* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT64;
|
/* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT64;
|
||||||
Default for 32-bit CPU mode. */
|
Default for 32-bit CPU mode. */
|
||||||
//#define MRB_INT32
|
//#define MRB_INT32
|
||||||
|
|
||||||
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT32;
|
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT32;
|
||||||
Default for 64-bit CPU mode. */
|
Default for 64-bit CPU mode (unless using MRB_NAN_BOXING). */
|
||||||
//#define MRB_INT64
|
//#define MRB_INT64
|
||||||
|
|
||||||
/* if no specific integer type is chosen */
|
/* if no specific integer type is chosen */
|
||||||
@@ -65,19 +101,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
|
/* call malloc_trim(0) from mrb_full_gc() */
|
||||||
#ifndef MRB_ENDIAN_BIG
|
//#define MRB_USE_MALLOC_TRIM
|
||||||
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
|
|
||||||
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
|
||||||
# define MRB_ENDIAN_BIG
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT and MRB_WITHOUT_FLOAT */
|
|
||||||
//#define MRB_NAN_BOXING
|
|
||||||
|
|
||||||
/* represent mrb_value as a word (natural unit of data for the processor) */
|
|
||||||
//#define MRB_WORD_BOXING
|
|
||||||
|
|
||||||
/* string class to handle UTF-8 encoding */
|
/* string class to handle UTF-8 encoding */
|
||||||
//#define MRB_UTF8_STRING
|
//#define MRB_UTF8_STRING
|
||||||
@@ -108,9 +133,6 @@
|
|||||||
/* page size of memory pool */
|
/* page size of memory pool */
|
||||||
//#define POOL_PAGE_SIZE 16000
|
//#define POOL_PAGE_SIZE 16000
|
||||||
|
|
||||||
/* initial minimum size for string buffer */
|
|
||||||
//#define MRB_STR_BUF_MIN_SIZE 128
|
|
||||||
|
|
||||||
/* arena size */
|
/* arena size */
|
||||||
//#define MRB_GC_ARENA_SIZE 100
|
//#define MRB_GC_ARENA_SIZE 100
|
||||||
|
|
||||||
@@ -123,26 +145,39 @@
|
|||||||
/* fixed size state atexit stack */
|
/* fixed size state atexit stack */
|
||||||
//#define MRB_FIXED_STATE_ATEXIT_STACK
|
//#define MRB_FIXED_STATE_ATEXIT_STACK
|
||||||
|
|
||||||
/* -DMRB_DISABLE_XXXX to drop following features */
|
/* -DMRB_NO_XXXX to drop following features */
|
||||||
//#define MRB_DISABLE_STDIO /* use of stdio */
|
//#define MRB_NO_STDIO /* use of stdio */
|
||||||
|
|
||||||
/* -DMRB_ENABLE_XXXX to enable following features */
|
/* -DMRB_USE_XXXX to enable following features */
|
||||||
//#define MRB_ENABLE_DEBUG_HOOK /* hooks for debugger */
|
//#define MRB_USE_DEBUG_HOOK /* hooks for debugger */
|
||||||
//#define MRB_ENABLE_ALL_SYMBOLS /* Symbols.all_symbols */
|
//#define MRB_USE_ALL_SYMBOLS /* Symbol.all_symbols */
|
||||||
|
|
||||||
|
/* obsolete configurations */
|
||||||
|
#ifdef MRB_METHOD_T_STRUCT
|
||||||
|
# define MRB_USE_METHOD_T_STRUCT
|
||||||
|
#endif
|
||||||
|
#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO)
|
||||||
|
# define MRB_NO_STDIO
|
||||||
|
#endif
|
||||||
|
#ifdef MRB_DISABLE_DIRECT_THREADING
|
||||||
|
# define MRB_NO_DIRECT_THREADING
|
||||||
|
#endif
|
||||||
|
#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK)
|
||||||
|
# define MRB_USE_DEBUG_HOOK
|
||||||
|
#endif
|
||||||
|
#ifdef MRB_ENABLE_ALL_SYMBOLS
|
||||||
|
# define MRB_USE_ALL_SYMBOLS
|
||||||
|
#endif
|
||||||
|
#ifdef MRB_ENABLE_CXX_ABI
|
||||||
|
# define MRB_USE_CXX_ABI
|
||||||
|
#endif
|
||||||
|
#ifdef MRB_ENABLE_CXX_EXCEPTION
|
||||||
|
# define MRB_USE_CXX_EXCEPTION
|
||||||
|
#endif
|
||||||
|
|
||||||
/* end of configuration */
|
/* end of configuration */
|
||||||
|
|
||||||
/* define MRB_DISABLE_XXXX from DISABLE_XXX (for compatibility) */
|
#ifndef MRB_NO_STDIO
|
||||||
#ifdef DISABLE_STDIO
|
|
||||||
#define MRB_DISABLE_STDIO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* define MRB_ENABLE_XXXX from ENABLE_XXX (for compatibility) */
|
|
||||||
#ifdef ENABLE_DEBUG
|
|
||||||
#define MRB_ENABLE_DEBUG_HOOK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MRB_DISABLE_STDIO
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -160,12 +195,12 @@
|
|||||||
|
|
||||||
/* A profile for micro controllers */
|
/* A profile for micro controllers */
|
||||||
#if defined(MRB_CONSTRAINED_BASELINE_PROFILE)
|
#if defined(MRB_CONSTRAINED_BASELINE_PROFILE)
|
||||||
# ifndef KHASH_DEFAULT_SIZE
|
# ifndef MRB_NO_METHOD_CACHE
|
||||||
# define KHASH_DEFAULT_SIZE 16
|
# define MRB_NO_METHOD_CACHE
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef MRB_STR_BUF_MIN_SIZE
|
# ifndef KHASH_DEFAULT_SIZE
|
||||||
# define MRB_STR_BUF_MIN_SIZE 32
|
# define KHASH_DEFAULT_SIZE 16
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef MRB_HEAP_PAGE_SIZE
|
# ifndef MRB_HEAP_PAGE_SIZE
|
||||||
@@ -177,36 +212,20 @@
|
|||||||
|
|
||||||
/* A profile for desktop computers or workstations; rich memory! */
|
/* A profile for desktop computers or workstations; rich memory! */
|
||||||
#elif defined(MRB_MAIN_PROFILE)
|
#elif defined(MRB_MAIN_PROFILE)
|
||||||
# ifndef MRB_METHOD_CACHE
|
|
||||||
# define MRB_METHOD_CACHE
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef MRB_METHOD_CACHE_SIZE
|
# ifndef MRB_METHOD_CACHE_SIZE
|
||||||
# define MRB_METHOD_CACHE_SIZE (1<<10)
|
# define MRB_METHOD_CACHE_SIZE (1<<10)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef MRB_IV_SEGMENT_SIZE
|
|
||||||
# define MRB_IV_SEGMENT_SIZE 32
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef MRB_HEAP_PAGE_SIZE
|
# ifndef MRB_HEAP_PAGE_SIZE
|
||||||
# define MRB_HEAP_PAGE_SIZE 4096
|
# define MRB_HEAP_PAGE_SIZE 4096
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* A profile for server; mruby vm is long life */
|
/* A profile for server; mruby vm is long life */
|
||||||
#elif defined(MRB_HIGH_PROFILE)
|
#elif defined(MRB_HIGH_PROFILE)
|
||||||
# ifndef MRB_METHOD_CACHE
|
|
||||||
# define MRB_METHOD_CACHE
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef MRB_METHOD_CACHE_SIZE
|
# ifndef MRB_METHOD_CACHE_SIZE
|
||||||
# define MRB_METHOD_CACHE_SIZE (1<<12)
|
# define MRB_METHOD_CACHE_SIZE (1<<12)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef MRB_IV_SEGMENT_SIZE
|
|
||||||
# define MRB_IV_SEGMENT_SIZE 64
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef MRB_HEAP_PAGE_SIZE
|
# ifndef MRB_HEAP_PAGE_SIZE
|
||||||
# define MRB_HEAP_PAGE_SIZE 4096
|
# define MRB_HEAP_PAGE_SIZE 4096
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
+137
-96
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** mruby - An embeddable Ruby implementation
|
** mruby - An embeddable Ruby implementation
|
||||||
**
|
**
|
||||||
** Copyright (c) mruby developers 2010-2020
|
** Copyright (c) mruby developers 2010-2021
|
||||||
**
|
**
|
||||||
** Permission is hereby granted, free of charge, to any person obtaining
|
** Permission is hereby granted, free of charge, to any person obtaining
|
||||||
** a copy of this software and associated documentation files (the
|
** a copy of this software and associated documentation files (the
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
**
|
**
|
||||||
** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
|
** [ MIT license: https://www.opensource.org/licenses/mit-license.php ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,6 +53,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define __func__ __FUNCTION__
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_DEBUG
|
#ifdef MRB_DEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define mrb_assert(p) assert(p)
|
#define mrb_assert(p) assert(p)
|
||||||
@@ -62,11 +66,27 @@
|
|||||||
#define mrb_assert_int_fit(t1,n,t2,max) ((void)0)
|
#define mrb_assert_int_fit(t1,n,t2,max) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
|
#if (defined __cplusplus && __cplusplus >= 201103L) || \
|
||||||
#define mrb_static_assert(exp, str) _Static_assert(exp, str)
|
(defined _MSC_VER) || \
|
||||||
|
(defined __GXX_EXPERIMENTAL_CXX0X__) /* for old G++/Clang++ */
|
||||||
|
# define mrb_static_assert(exp, str) static_assert(exp, str)
|
||||||
|
#elif defined __STDC_VERSION__ && \
|
||||||
|
((__STDC_VERSION__ >= 201112L) || \
|
||||||
|
(defined __GNUC__ && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
|
||||||
|
# define mrb_static_assert(exp, str) _Static_assert(exp, str)
|
||||||
#else
|
#else
|
||||||
#define mrb_static_assert(exp, str) mrb_assert(exp)
|
# /* alternative implementation of static_assert() */
|
||||||
|
# define _mrb_static_assert_cat0(a, b) a##b
|
||||||
|
# define _mrb_static_assert_cat(a, b) _mrb_static_assert_cat0(a, b)
|
||||||
|
# ifdef __COUNTER__
|
||||||
|
# define _mrb_static_assert_id(prefix) _mrb_static_assert_cat(prefix, __COUNTER__)
|
||||||
|
# else
|
||||||
|
# define _mrb_static_assert_id(prefix) _mrb_static_assert_cat(prefix, __LINE__)
|
||||||
|
# endif
|
||||||
|
# define mrb_static_assert(exp, str) \
|
||||||
|
struct _mrb_static_assert_id(_mrb_static_assert_) { char x[(exp) ? 1 : -1]; }
|
||||||
#endif
|
#endif
|
||||||
|
#define mrb_static_assert1(exp) mrb_static_assert(exp, #exp)
|
||||||
|
|
||||||
#include "mrbconf.h"
|
#include "mrbconf.h"
|
||||||
|
|
||||||
@@ -75,7 +95,7 @@
|
|||||||
#include <mruby/gc.h>
|
#include <mruby/gc.h>
|
||||||
#include <mruby/version.h>
|
#include <mruby/version.h>
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#ifndef FLT_EPSILON
|
#ifndef FLT_EPSILON
|
||||||
#define FLT_EPSILON (1.19209290e-07f)
|
#define FLT_EPSILON (1.19209290e-07f)
|
||||||
@@ -87,7 +107,7 @@
|
|||||||
#define LDBL_EPSILON (1.08420217248550443401e-19L)
|
#define LDBL_EPSILON (1.08420217248550443401e-19L)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_USE_FLOAT
|
#ifdef MRB_USE_FLOAT32
|
||||||
#define MRB_FLOAT_EPSILON FLT_EPSILON
|
#define MRB_FLOAT_EPSILON FLT_EPSILON
|
||||||
#else
|
#else
|
||||||
#define MRB_FLOAT_EPSILON DBL_EPSILON
|
#define MRB_FLOAT_EPSILON DBL_EPSILON
|
||||||
@@ -130,16 +150,15 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mrb_sym mid;
|
mrb_sym mid;
|
||||||
struct RProc *proc;
|
int16_t argc;
|
||||||
mrb_value *stackent;
|
int16_t acc;
|
||||||
uint16_t ridx;
|
const struct RProc *proc;
|
||||||
uint16_t epos;
|
mrb_value *stack;
|
||||||
struct REnv *env;
|
const mrb_code *pc; /* current address on iseq of this proc */
|
||||||
const mrb_code *pc; /* return address */
|
union {
|
||||||
const mrb_code *err; /* error position */
|
struct REnv *env;
|
||||||
int argc;
|
struct RClass *target_class;
|
||||||
int acc;
|
} u;
|
||||||
struct RClass *target_class;
|
|
||||||
} mrb_callinfo;
|
} mrb_callinfo;
|
||||||
|
|
||||||
enum mrb_fiber_state {
|
enum mrb_fiber_state {
|
||||||
@@ -154,28 +173,22 @@ enum mrb_fiber_state {
|
|||||||
struct mrb_context {
|
struct mrb_context {
|
||||||
struct mrb_context *prev;
|
struct mrb_context *prev;
|
||||||
|
|
||||||
mrb_value *stack; /* stack of virtual machine */
|
mrb_value *stbase, *stend; /* stack of virtual machine */
|
||||||
mrb_value *stbase, *stend;
|
|
||||||
|
|
||||||
mrb_callinfo *ci;
|
mrb_callinfo *ci;
|
||||||
mrb_callinfo *cibase, *ciend;
|
mrb_callinfo *cibase, *ciend;
|
||||||
|
|
||||||
uint16_t *rescue; /* exception handler stack */
|
|
||||||
uint16_t rsize;
|
|
||||||
struct RProc **ensure; /* ensure handler stack */
|
|
||||||
uint16_t esize, eidx;
|
|
||||||
|
|
||||||
enum mrb_fiber_state status : 4;
|
enum mrb_fiber_state status : 4;
|
||||||
mrb_bool vmexec : 1;
|
mrb_bool vmexec : 1;
|
||||||
struct RFiber *fib;
|
struct RFiber *fib;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MRB_METHOD_CACHE_SIZE
|
#ifdef MRB_METHOD_CACHE_SIZE
|
||||||
# define MRB_METHOD_CACHE
|
# undef MRB_NO_METHOD_CACHE
|
||||||
#else
|
#else
|
||||||
/* default method cache size: 128 */
|
/* default method cache size: 256 */
|
||||||
/* cache size needs to be power of 2 */
|
/* cache size needs to be power of 2 */
|
||||||
# define MRB_METHOD_CACHE_SIZE (1<<7)
|
# define MRB_METHOD_CACHE_SIZE (1<<8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,7 +202,7 @@ struct mrb_context {
|
|||||||
*/
|
*/
|
||||||
typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value self);
|
typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value self);
|
||||||
|
|
||||||
#ifndef MRB_METHOD_T_STRUCT
|
#ifndef MRB_USE_METHOD_T_STRUCT
|
||||||
typedef uintptr_t mrb_method_t;
|
typedef uintptr_t mrb_method_t;
|
||||||
#else
|
#else
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -201,7 +214,7 @@ typedef struct {
|
|||||||
} mrb_method_t;
|
} mrb_method_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_METHOD_CACHE
|
#ifndef MRB_NO_METHOD_CACHE
|
||||||
struct mrb_cache_entry {
|
struct mrb_cache_entry {
|
||||||
struct RClass *c, *c0;
|
struct RClass *c, *c0;
|
||||||
mrb_sym mid;
|
mrb_sym mid;
|
||||||
@@ -235,10 +248,10 @@ typedef struct mrb_state {
|
|||||||
struct RClass *hash_class;
|
struct RClass *hash_class;
|
||||||
struct RClass *range_class;
|
struct RClass *range_class;
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
struct RClass *float_class;
|
struct RClass *float_class;
|
||||||
#endif
|
#endif
|
||||||
struct RClass *fixnum_class;
|
struct RClass *integer_class;
|
||||||
struct RClass *true_class;
|
struct RClass *true_class;
|
||||||
struct RClass *false_class;
|
struct RClass *false_class;
|
||||||
struct RClass *nil_class;
|
struct RClass *nil_class;
|
||||||
@@ -247,7 +260,7 @@ typedef struct mrb_state {
|
|||||||
|
|
||||||
mrb_gc gc;
|
mrb_gc gc;
|
||||||
|
|
||||||
#ifdef MRB_METHOD_CACHE
|
#ifndef MRB_NO_METHOD_CACHE
|
||||||
struct mrb_cache_entry cache[MRB_METHOD_CACHE_SIZE];
|
struct mrb_cache_entry cache[MRB_METHOD_CACHE_SIZE];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -255,13 +268,13 @@ typedef struct mrb_state {
|
|||||||
struct symbol_name *symtbl; /* symbol table */
|
struct symbol_name *symtbl; /* symbol table */
|
||||||
mrb_sym symhash[256];
|
mrb_sym symhash[256];
|
||||||
size_t symcapa;
|
size_t symcapa;
|
||||||
#ifndef MRB_ENABLE_SYMBOLL_ALL
|
#ifndef MRB_USE_ALL_SYMBOLS
|
||||||
char symbuf[8]; /* buffer for small symbol names */
|
char symbuf[8]; /* buffer for small symbol names */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_ENABLE_DEBUG_HOOK
|
#ifdef MRB_USE_DEBUG_HOOK
|
||||||
void (*code_fetch_hook)(struct mrb_state* mrb, struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
void (*code_fetch_hook)(struct mrb_state* mrb, const struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
||||||
void (*debug_op_hook)(struct mrb_state* mrb, struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
void (*debug_op_hook)(struct mrb_state* mrb, const struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_BYTECODE_DECODE_OPTION
|
#ifdef MRB_BYTECODE_DECODE_OPTION
|
||||||
@@ -273,7 +286,7 @@ typedef struct mrb_state {
|
|||||||
struct RObject *nomem_err; /* pre-allocated NoMemoryError */
|
struct RObject *nomem_err; /* pre-allocated NoMemoryError */
|
||||||
struct RObject *stack_err; /* pre-allocated SysStackError */
|
struct RObject *stack_err; /* pre-allocated SysStackError */
|
||||||
#ifdef MRB_GC_FIXED_ARENA
|
#ifdef MRB_GC_FIXED_ARENA
|
||||||
struct RObject *arena_err; /* pre-allocated arena overfow error */
|
struct RObject *arena_err; /* pre-allocated arena overflow error */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *ud; /* auxiliary data */
|
void *ud; /* auxiliary data */
|
||||||
@@ -284,7 +297,6 @@ typedef struct mrb_state {
|
|||||||
mrb_atexit_func *atexit_stack;
|
mrb_atexit_func *atexit_stack;
|
||||||
#endif
|
#endif
|
||||||
uint16_t atexit_stack_len;
|
uint16_t atexit_stack_len;
|
||||||
uint16_t ecall_nest; /* prevent infinite recursive ecall() */
|
|
||||||
} mrb_state;
|
} mrb_state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -309,6 +321,7 @@ typedef struct mrb_state {
|
|||||||
* @see mrb_define_class_under
|
* @see mrb_define_class_under
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass *mrb_define_class(mrb_state *mrb, const char *name, struct RClass *super);
|
MRB_API struct RClass *mrb_define_class(mrb_state *mrb, const char *name, struct RClass *super);
|
||||||
|
MRB_API struct RClass *mrb_define_class_id(mrb_state *mrb, mrb_sym name, struct RClass *super);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a new module.
|
* Defines a new module.
|
||||||
@@ -318,6 +331,7 @@ MRB_API struct RClass *mrb_define_class(mrb_state *mrb, const char *name, struct
|
|||||||
* @return [struct RClass *] Reference to the newly defined module.
|
* @return [struct RClass *] Reference to the newly defined module.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass *mrb_define_module(mrb_state *mrb, const char *name);
|
MRB_API struct RClass *mrb_define_module(mrb_state *mrb, const char *name);
|
||||||
|
MRB_API struct RClass *mrb_define_module_id(mrb_state *mrb, mrb_sym name);
|
||||||
|
|
||||||
MRB_API mrb_value mrb_singleton_class(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_singleton_class(mrb_state *mrb, mrb_value val);
|
||||||
MRB_API struct RClass *mrb_singleton_class_ptr(mrb_state *mrb, mrb_value val);
|
MRB_API struct RClass *mrb_singleton_class_ptr(mrb_state *mrb, mrb_value val);
|
||||||
@@ -373,6 +387,7 @@ MRB_API void mrb_prepend_module(mrb_state *mrb, struct RClass *cla, struct RClas
|
|||||||
* @param aspec The method parameters declaration.
|
* @param aspec The method parameters declaration.
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
|
MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
|
||||||
|
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a class method.
|
* Defines a class method.
|
||||||
@@ -400,6 +415,7 @@ MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *n
|
|||||||
* @param aspec The method parameters declaration.
|
* @param aspec The method parameters declaration.
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_define_class_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
MRB_API void mrb_define_class_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
MRB_API void mrb_define_class_method_id(mrb_state *mrb, struct RClass *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a singleton method
|
* Defines a singleton method
|
||||||
@@ -407,6 +423,7 @@ MRB_API void mrb_define_class_method(mrb_state *mrb, struct RClass *cla, const c
|
|||||||
* @see mrb_define_class_method
|
* @see mrb_define_class_method
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_define_singleton_method(mrb_state *mrb, struct RObject *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
MRB_API void mrb_define_singleton_method(mrb_state *mrb, struct RObject *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
MRB_API void mrb_define_singleton_method_id(mrb_state *mrb, struct RObject *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a module function.
|
* Defines a module function.
|
||||||
@@ -434,6 +451,7 @@ MRB_API void mrb_define_singleton_method(mrb_state *mrb, struct RObject *cla, co
|
|||||||
* @param aspec The method parameters declaration.
|
* @param aspec The method parameters declaration.
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_define_module_function(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
MRB_API void mrb_define_module_function(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
MRB_API void mrb_define_module_function_id(mrb_state *mrb, struct RClass *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a constant.
|
* Defines a constant.
|
||||||
@@ -462,6 +480,7 @@ MRB_API void mrb_define_module_function(mrb_state *mrb, struct RClass *cla, cons
|
|||||||
* @param val The value for the constant.
|
* @param val The value for the constant.
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_define_const(mrb_state* mrb, struct RClass* cla, const char *name, mrb_value val);
|
MRB_API void mrb_define_const(mrb_state* mrb, struct RClass* cla, const char *name, mrb_value val);
|
||||||
|
MRB_API void mrb_define_const_id(mrb_state* mrb, struct RClass* cla, mrb_sym name, mrb_value val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undefines a method.
|
* Undefines a method.
|
||||||
@@ -552,6 +571,7 @@ MRB_API void mrb_undef_method_id(mrb_state*, struct RClass*, mrb_sym);
|
|||||||
* @param name The name of the class method to be undefined.
|
* @param name The name of the class method to be undefined.
|
||||||
*/
|
*/
|
||||||
MRB_API void mrb_undef_class_method(mrb_state *mrb, struct RClass *cls, const char *name);
|
MRB_API void mrb_undef_class_method(mrb_state *mrb, struct RClass *cls, const char *name);
|
||||||
|
MRB_API void mrb_undef_class_method_id(mrb_state *mrb, struct RClass *cls, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a new object instance of c class.
|
* Initialize a new object instance of c class.
|
||||||
@@ -653,6 +673,7 @@ MRB_API struct RClass * mrb_module_new(mrb_state *mrb);
|
|||||||
* @return [mrb_bool] A boolean value.
|
* @return [mrb_bool] A boolean value.
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name);
|
MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name);
|
||||||
|
MRB_API mrb_bool mrb_class_defined_id(mrb_state *mrb, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a class.
|
* Gets a class.
|
||||||
@@ -660,7 +681,8 @@ MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name);
|
|||||||
* @param name The name of the class.
|
* @param name The name of the class.
|
||||||
* @return [struct RClass *] A reference to the class.
|
* @return [struct RClass *] A reference to the class.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
|
MRB_API struct RClass* mrb_class_get(mrb_state *mrb, const char *name);
|
||||||
|
MRB_API struct RClass* mrb_class_get_id(mrb_state *mrb, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a exception class.
|
* Gets a exception class.
|
||||||
@@ -668,7 +690,8 @@ MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
|
|||||||
* @param name The name of the class.
|
* @param name The name of the class.
|
||||||
* @return [struct RClass *] A reference to the class.
|
* @return [struct RClass *] A reference to the class.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
|
MRB_API struct RClass* mrb_exc_get_id(mrb_state *mrb, mrb_sym name);
|
||||||
|
#define mrb_exc_get(mrb, name) mrb_exc_get_id(mrb, mrb_intern_cstr(mrb, name))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined.
|
* Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined.
|
||||||
@@ -700,6 +723,7 @@ MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
|
|||||||
* @return [mrb_bool] A boolean value.
|
* @return [mrb_bool] A boolean value.
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
||||||
|
MRB_API mrb_bool mrb_class_defined_under_id(mrb_state *mrb, struct RClass *outer, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a child class.
|
* Gets a child class.
|
||||||
@@ -709,6 +733,7 @@ MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, c
|
|||||||
* @return [struct RClass *] A reference to the class.
|
* @return [struct RClass *] A reference to the class.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_class_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
MRB_API struct RClass * mrb_class_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
||||||
|
MRB_API struct RClass * mrb_class_get_under_id(mrb_state *mrb, struct RClass *outer, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a module.
|
* Gets a module.
|
||||||
@@ -717,6 +742,7 @@ MRB_API struct RClass * mrb_class_get_under(mrb_state *mrb, struct RClass *outer
|
|||||||
* @return [struct RClass *] A reference to the module.
|
* @return [struct RClass *] A reference to the module.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_module_get(mrb_state *mrb, const char *name);
|
MRB_API struct RClass * mrb_module_get(mrb_state *mrb, const char *name);
|
||||||
|
MRB_API struct RClass * mrb_module_get_id(mrb_state *mrb, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a module defined under another module.
|
* Gets a module defined under another module.
|
||||||
@@ -726,6 +752,8 @@ MRB_API struct RClass * mrb_module_get(mrb_state *mrb, const char *name);
|
|||||||
* @return [struct RClass *] A reference to the module.
|
* @return [struct RClass *] A reference to the module.
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_module_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
MRB_API struct RClass * mrb_module_get_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
||||||
|
MRB_API struct RClass * mrb_module_get_under_id(mrb_state *mrb, struct RClass *outer, mrb_sym name);
|
||||||
|
|
||||||
/* a function to raise NotImplementedError with current method name */
|
/* a function to raise NotImplementedError with current method name */
|
||||||
MRB_API void mrb_notimplement(mrb_state*);
|
MRB_API void mrb_notimplement(mrb_state*);
|
||||||
/* a function to be replacement of unimplemented method */
|
/* a function to be replacement of unimplemented method */
|
||||||
@@ -794,9 +822,11 @@ MRB_API mrb_bool mrb_obj_respond_to(mrb_state *mrb, struct RClass* c, mrb_sym mi
|
|||||||
* @return [struct RClass *] Reference to the newly defined class
|
* @return [struct RClass *] Reference to the newly defined class
|
||||||
* @see mrb_define_class
|
* @see mrb_define_class
|
||||||
*/
|
*/
|
||||||
MRB_API struct RClass * mrb_define_class_under(mrb_state *mrb, struct RClass *outer, const char *name, struct RClass *super);
|
MRB_API struct RClass* mrb_define_class_under(mrb_state *mrb, struct RClass *outer, const char *name, struct RClass *super);
|
||||||
|
MRB_API struct RClass* mrb_define_class_under_id(mrb_state *mrb, struct RClass *outer, mrb_sym name, struct RClass *super);
|
||||||
|
|
||||||
MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
MRB_API struct RClass* mrb_define_module_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
||||||
|
MRB_API struct RClass* mrb_define_module_under_id(mrb_state *mrb, struct RClass *outer, mrb_sym name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function requires n arguments.
|
* Function requires n arguments.
|
||||||
@@ -860,17 +890,17 @@ MRB_API struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *o
|
|||||||
* | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
|
* | `S` | {String} | {mrb_value} | when `!` follows, the value may be `nil` |
|
||||||
* | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
|
* | `A` | {Array} | {mrb_value} | when `!` follows, the value may be `nil` |
|
||||||
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
|
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
|
||||||
* | `s` | {String} | char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
|
* | `s` | {String} | const char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
|
||||||
* | `z` | {String} | char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
|
* | `z` | {String} | const char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
|
||||||
* | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
|
* | `a` | {Array} | const {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
|
||||||
* | `f` | {Fixnum}/{Float} | {mrb_float} | |
|
* | `f` | {Integer}/{Float} | {mrb_float} | |
|
||||||
* | `i` | {Fixnum}/{Float} | {mrb_int} | |
|
* | `i` | {Integer}/{Float} | {mrb_int} | |
|
||||||
* | `b` | boolean | {mrb_bool} | |
|
* | `b` | boolean | {mrb_bool} | |
|
||||||
* | `n` | {String}/{Symbol} | {mrb_sym} | |
|
* | `n` | {String}/{Symbol} | {mrb_sym} | |
|
||||||
* | `d` | data | void *, {mrb_data_type} const | 2nd argument will be used to check data type so it won't be modified; when `!` follows, the value may be `nil` |
|
* | `d` | data | void *, {mrb_data_type} const | 2nd argument will be used to check data type so it won't be modified; when `!` follows, the value may be `nil` |
|
||||||
* | `I` | inline struct | void * | |
|
* | `I` | inline struct | void * | |
|
||||||
* | `&` | block | {mrb_value} | &! raises exception if no block given. |
|
* | `&` | block | {mrb_value} | &! raises exception if no block given. |
|
||||||
* | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
|
* | `*` | rest arguments | const {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
|
||||||
* | <code>\|</code> | optional | | After this spec following specs would be optional. |
|
* | <code>\|</code> | optional | | After this spec following specs would be optional. |
|
||||||
* | `?` | optional given | {mrb_bool} | `TRUE` if preceding argument is given. Used to check optional argument is given. |
|
* | `?` | optional given | {mrb_bool} | `TRUE` if preceding argument is given. Used to check optional argument is given. |
|
||||||
* | `:` | keyword args | {mrb_kwargs} const | Get keyword arguments. @see mrb_kwargs |
|
* | `:` | keyword args | {mrb_kwargs} const | Get keyword arguments. @see mrb_kwargs |
|
||||||
@@ -902,7 +932,7 @@ typedef const char *mrb_args_format;
|
|||||||
* const char *kw_names[kw_num] = { "a", "b" };
|
* const char *kw_names[kw_num] = { "a", "b" };
|
||||||
* uint32_t kw_required = 0;
|
* uint32_t kw_required = 0;
|
||||||
* mrb_value kw_values[kw_num];
|
* mrb_value kw_values[kw_num];
|
||||||
* const mrb_kwargs kwargs = { kw_num, kw_values, kw_names, kw_required, NULL };
|
* const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, NULL };
|
||||||
*
|
*
|
||||||
* mrb_get_args(mrb, ":", &kwargs);
|
* mrb_get_args(mrb, ":", &kwargs);
|
||||||
* if (mrb_undef_p(kw_values[0])) { kw_values[0] = mrb_fixnum_value(1); }
|
* if (mrb_undef_p(kw_values[0])) { kw_values[0] = mrb_fixnum_value(1); }
|
||||||
@@ -913,10 +943,10 @@ typedef const char *mrb_args_format;
|
|||||||
*
|
*
|
||||||
* mrb_value str, kw_rest;
|
* mrb_value str, kw_rest;
|
||||||
* uint32_t kw_num = 3;
|
* uint32_t kw_num = 3;
|
||||||
* const char *kw_names[kw_num] = { "x", "y", "z" };
|
* const mrb_sym kw_names[kw_num] = { MRB_SYM(x), MRB_SYM(y), MRB_SYM(z) };
|
||||||
* uint32_t kw_required = 1;
|
* uint32_t kw_required = 1;
|
||||||
* mrb_value kw_values[kw_num];
|
* mrb_value kw_values[kw_num];
|
||||||
* const mrb_kwargs kwargs = { kw_num, kw_values, kw_names, kw_required, &kw_rest };
|
* const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, &kw_rest };
|
||||||
*
|
*
|
||||||
* mrb_get_args(mrb, "S:", &str, &kwargs);
|
* mrb_get_args(mrb, "S:", &str, &kwargs);
|
||||||
* // or: mrb_get_args(mrb, ":S", &kwargs, &str);
|
* // or: mrb_get_args(mrb, ":S", &kwargs, &str);
|
||||||
@@ -927,11 +957,11 @@ typedef struct mrb_kwargs mrb_kwargs;
|
|||||||
|
|
||||||
struct mrb_kwargs
|
struct mrb_kwargs
|
||||||
{
|
{
|
||||||
uint32_t num;
|
uint32_t num; /* number of keyword arguments */
|
||||||
mrb_value *values;
|
uint32_t required; /* number of required keyword arguments */
|
||||||
const char *const *table;
|
const mrb_sym *table; /* C array of symbols for keyword names */
|
||||||
uint32_t required;
|
mrb_value *values; /* keyword argument values */
|
||||||
mrb_value *rest;
|
mrb_value *rest; /* keyword rest (dict) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -964,7 +994,7 @@ MRB_API mrb_int mrb_get_argc(mrb_state *mrb);
|
|||||||
*
|
*
|
||||||
* Correctly handles *splat arguments.
|
* Correctly handles *splat arguments.
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_value* mrb_get_argv(mrb_state *mrb);
|
MRB_API const mrb_value *mrb_get_argv(mrb_state *mrb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the first and only argument from mrb_state.
|
* Retrieve the first and only argument from mrb_state.
|
||||||
@@ -1001,6 +1031,7 @@ MRB_API mrb_value mrb_get_arg1(mrb_state *mrb);
|
|||||||
* FILE *fp = fopen("test.rb","r");
|
* FILE *fp = fopen("test.rb","r");
|
||||||
* mrb_value obj = mrb_load_file(mrb,fp);
|
* mrb_value obj = mrb_load_file(mrb,fp);
|
||||||
* mrb_funcall(mrb, obj, "method_name", 1, mrb_fixnum_value(i));
|
* mrb_funcall(mrb, obj, "method_name", 1, mrb_fixnum_value(i));
|
||||||
|
* mrb_funcall_id(mrb, obj, MRB_SYM(method_name), 1, mrb_fixnum_value(i));
|
||||||
* fclose(fp);
|
* fclose(fp);
|
||||||
* mrb_close(mrb);
|
* mrb_close(mrb);
|
||||||
* }
|
* }
|
||||||
@@ -1013,6 +1044,7 @@ MRB_API mrb_value mrb_get_arg1(mrb_state *mrb);
|
|||||||
* @return [mrb_value] mruby function value.
|
* @return [mrb_value] mruby function value.
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_value mrb_funcall(mrb_state *mrb, mrb_value val, const char *name, mrb_int argc, ...);
|
MRB_API mrb_value mrb_funcall(mrb_state *mrb, mrb_value val, const char *name, mrb_int argc, ...);
|
||||||
|
MRB_API mrb_value mrb_funcall_id(mrb_state *mrb, mrb_value val, mrb_sym mid, mrb_int argc, ...);
|
||||||
/**
|
/**
|
||||||
* Call existing ruby functions. This is basically the type safe version of mrb_funcall.
|
* Call existing ruby functions. This is basically the type safe version of mrb_funcall.
|
||||||
*
|
*
|
||||||
@@ -1022,15 +1054,14 @@ MRB_API mrb_value mrb_funcall(mrb_state *mrb, mrb_value val, const char *name, m
|
|||||||
* int
|
* int
|
||||||
* main()
|
* main()
|
||||||
* {
|
* {
|
||||||
* mrb_int i = 99;
|
|
||||||
* mrb_state *mrb = mrb_open();
|
* mrb_state *mrb = mrb_open();
|
||||||
|
* mrb_value obj = mrb_fixnum_value(1);
|
||||||
*
|
*
|
||||||
* if (!mrb) { }
|
* if (!mrb) { }
|
||||||
* mrb_sym m_sym = mrb_intern_lit(mrb, "method_name"); // Symbol for method.
|
|
||||||
*
|
*
|
||||||
* FILE *fp = fopen("test.rb","r");
|
* FILE *fp = fopen("test.rb","r");
|
||||||
* mrb_value obj = mrb_load_file(mrb,fp);
|
* mrb_value obj = mrb_load_file(mrb,fp);
|
||||||
* mrb_funcall_argv(mrb, obj, m_sym, 1, &obj); // Calling ruby function from test.rb.
|
* mrb_funcall_argv(mrb, obj, MRB_SYM(method_name), 1, &obj); // Calling ruby function from test.rb.
|
||||||
* fclose(fp);
|
* fclose(fp);
|
||||||
* mrb_close(mrb);
|
* mrb_close(mrb);
|
||||||
* }
|
* }
|
||||||
@@ -1048,7 +1079,8 @@ MRB_API mrb_value mrb_funcall_argv(mrb_state *mrb, mrb_value val, mrb_sym name,
|
|||||||
*/
|
*/
|
||||||
MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block);
|
MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block);
|
||||||
/**
|
/**
|
||||||
* Create a symbol
|
* Create a symbol from C string. But usually it's better to use MRB_SYM,
|
||||||
|
* MRB_OPSYM, MRB_CVSYM, MRB_IVSYM, MRB_SYM_B, MRB_SYM_Q, MRB_SYM_E macros.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
@@ -1056,7 +1088,9 @@ MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym
|
|||||||
* :pizza # => :pizza
|
* :pizza # => :pizza
|
||||||
*
|
*
|
||||||
* // C style:
|
* // C style:
|
||||||
* mrb_sym m_sym = mrb_intern_lit(mrb, "pizza"); // => :pizza
|
* mrb_sym sym1 = mrb_intern_lit(mrb, "pizza"); // => :pizza
|
||||||
|
* mrb_sym sym2 = MRB_SYM(pizza); // => :pizza
|
||||||
|
* mrb_sym sym3 = MRB_SYM_Q(pizza); // => :pizza?
|
||||||
*
|
*
|
||||||
* @param mrb The current mruby state.
|
* @param mrb The current mruby state.
|
||||||
* @param str The string to be symbolized
|
* @param str The string to be symbolized
|
||||||
@@ -1065,8 +1099,14 @@ MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym
|
|||||||
MRB_API mrb_sym mrb_intern_cstr(mrb_state *mrb, const char* str);
|
MRB_API mrb_sym mrb_intern_cstr(mrb_state *mrb, const char* str);
|
||||||
MRB_API mrb_sym mrb_intern(mrb_state*,const char*,size_t);
|
MRB_API mrb_sym mrb_intern(mrb_state*,const char*,size_t);
|
||||||
MRB_API mrb_sym mrb_intern_static(mrb_state*,const char*,size_t);
|
MRB_API mrb_sym mrb_intern_static(mrb_state*,const char*,size_t);
|
||||||
#define mrb_intern_lit(mrb, lit) mrb_intern_static(mrb, lit, mrb_strlen_lit(lit))
|
#define mrb_intern_lit(mrb, lit) mrb_intern_static(mrb, (lit ""), mrb_strlen_lit(lit))
|
||||||
MRB_API mrb_sym mrb_intern_str(mrb_state*,mrb_value);
|
MRB_API mrb_sym mrb_intern_str(mrb_state*,mrb_value);
|
||||||
|
/* mrb_intern_check series functions returns 0 if the symbol is not defined */
|
||||||
|
MRB_API mrb_sym mrb_intern_check_cstr(mrb_state*,const char*);
|
||||||
|
MRB_API mrb_sym mrb_intern_check(mrb_state*,const char*,size_t);
|
||||||
|
MRB_API mrb_sym mrb_intern_check_str(mrb_state*,mrb_value);
|
||||||
|
/* mrb_check_intern series functions returns nil if the symbol is not defined */
|
||||||
|
/* otherwise returns mrb_value */
|
||||||
MRB_API mrb_value mrb_check_intern_cstr(mrb_state*,const char*);
|
MRB_API mrb_value mrb_check_intern_cstr(mrb_state*,const char*);
|
||||||
MRB_API mrb_value mrb_check_intern(mrb_state*,const char*,size_t);
|
MRB_API mrb_value mrb_check_intern(mrb_state*,const char*,size_t);
|
||||||
MRB_API mrb_value mrb_check_intern_str(mrb_state*,mrb_value);
|
MRB_API mrb_value mrb_check_intern_str(mrb_state*,mrb_value);
|
||||||
@@ -1164,9 +1204,9 @@ MRB_API void mrb_close(mrb_state *mrb);
|
|||||||
MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*);
|
MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*);
|
||||||
|
|
||||||
MRB_API mrb_value mrb_top_self(mrb_state *mrb);
|
MRB_API mrb_value mrb_top_self(mrb_state *mrb);
|
||||||
MRB_API mrb_value mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep);
|
MRB_API mrb_value mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep);
|
||||||
MRB_API mrb_value mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep);
|
MRB_API mrb_value mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep);
|
||||||
MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, struct RProc *proc, const mrb_code *iseq);
|
MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *iseq);
|
||||||
/* compatibility macros */
|
/* compatibility macros */
|
||||||
#define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k))
|
#define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k))
|
||||||
#define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0)
|
#define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0)
|
||||||
@@ -1181,7 +1221,7 @@ MRB_API mrb_bool mrb_obj_equal(mrb_state *mrb, mrb_value a, mrb_value b);
|
|||||||
MRB_API mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
|
MRB_API mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
|
||||||
MRB_API mrb_value mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base);
|
MRB_API mrb_value mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base);
|
||||||
MRB_API mrb_value mrb_Integer(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_Integer(mrb_state *mrb, mrb_value val);
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
MRB_API mrb_value mrb_Float(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_Float(mrb_state *mrb, mrb_value val);
|
||||||
#endif
|
#endif
|
||||||
MRB_API mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj);
|
MRB_API mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj);
|
||||||
@@ -1214,12 +1254,15 @@ MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*
|
|||||||
} while (0)
|
} while (0)
|
||||||
MRB_API void mrb_write_barrier(mrb_state *, struct RBasic*);
|
MRB_API void mrb_write_barrier(mrb_state *, struct RBasic*);
|
||||||
|
|
||||||
MRB_API mrb_value mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method);
|
MRB_API mrb_value mrb_type_convert(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
|
||||||
|
#define mrb_convert_type(mrb, val, type, tname, method) mrb_type_convert(mrb, val, type, mrb_intern_lit(mrb, method))
|
||||||
|
MRB_API mrb_value mrb_type_convert_check(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method);
|
||||||
|
#define mrb_check_convert_type(mrb, val, type, tname, method) mrb_type_convert_check(mrb, val, type, mrb_intern_lit(mrb, method))
|
||||||
|
|
||||||
MRB_API mrb_value mrb_any_to_s(mrb_state *mrb, mrb_value obj);
|
MRB_API mrb_value mrb_any_to_s(mrb_state *mrb, mrb_value obj);
|
||||||
MRB_API const char * mrb_obj_classname(mrb_state *mrb, mrb_value obj);
|
MRB_API const char * mrb_obj_classname(mrb_state *mrb, mrb_value obj);
|
||||||
MRB_API struct RClass* mrb_obj_class(mrb_state *mrb, mrb_value obj);
|
MRB_API struct RClass* mrb_obj_class(mrb_state *mrb, mrb_value obj);
|
||||||
MRB_API mrb_value mrb_class_path(mrb_state *mrb, struct RClass *c);
|
MRB_API mrb_value mrb_class_path(mrb_state *mrb, struct RClass *c);
|
||||||
MRB_API mrb_value mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method);
|
|
||||||
MRB_API mrb_bool mrb_obj_is_kind_of(mrb_state *mrb, mrb_value obj, struct RClass *c);
|
MRB_API mrb_bool mrb_obj_is_kind_of(mrb_state *mrb, mrb_value obj, struct RClass *c);
|
||||||
MRB_API mrb_value mrb_obj_inspect(mrb_state *mrb, mrb_value self);
|
MRB_API mrb_value mrb_obj_inspect(mrb_state *mrb, mrb_value self);
|
||||||
MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);
|
MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);
|
||||||
@@ -1260,26 +1303,26 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
|
|||||||
+ those E_* macros requires mrb_state* variable named mrb.
|
+ those E_* macros requires mrb_state* variable named mrb.
|
||||||
+ exception objects obtained from those macros are local to mrb
|
+ exception objects obtained from those macros are local to mrb
|
||||||
*/
|
*/
|
||||||
#define E_RUNTIME_ERROR (mrb_exc_get(mrb, "RuntimeError"))
|
#define MRB_ERROR_SYM(sym) mrb_intern_lit(mrb, #sym)
|
||||||
#define E_TYPE_ERROR (mrb_exc_get(mrb, "TypeError"))
|
#define E_RUNTIME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError))
|
||||||
#define E_ARGUMENT_ERROR (mrb_exc_get(mrb, "ArgumentError"))
|
#define E_TYPE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError))
|
||||||
#define E_INDEX_ERROR (mrb_exc_get(mrb, "IndexError"))
|
#define E_ZERODIV_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError))
|
||||||
#define E_RANGE_ERROR (mrb_exc_get(mrb, "RangeError"))
|
#define E_ARGUMENT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ArgumentError))
|
||||||
#define E_NAME_ERROR (mrb_exc_get(mrb, "NameError"))
|
#define E_INDEX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(IndexError))
|
||||||
#define E_NOMETHOD_ERROR (mrb_exc_get(mrb, "NoMethodError"))
|
#define E_RANGE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RangeError))
|
||||||
#define E_SCRIPT_ERROR (mrb_exc_get(mrb, "ScriptError"))
|
#define E_NAME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NameError))
|
||||||
#define E_SYNTAX_ERROR (mrb_exc_get(mrb, "SyntaxError"))
|
#define E_NOMETHOD_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMethodError))
|
||||||
#define E_LOCALJUMP_ERROR (mrb_exc_get(mrb, "LocalJumpError"))
|
#define E_SCRIPT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ScriptError))
|
||||||
#define E_REGEXP_ERROR (mrb_exc_get(mrb, "RegexpError"))
|
#define E_SYNTAX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(SyntaxError))
|
||||||
#define E_FROZEN_ERROR (mrb_exc_get(mrb, "FrozenError"))
|
#define E_LOCALJUMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(LocalJumpError))
|
||||||
|
#define E_REGEXP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RegexpError))
|
||||||
#define E_NOTIMP_ERROR (mrb_exc_get(mrb, "NotImplementedError"))
|
#define E_FROZEN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FrozenError))
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#define E_NOTIMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NotImplementedError))
|
||||||
#define E_FLOATDOMAIN_ERROR (mrb_exc_get(mrb, "FloatDomainError"))
|
#define E_KEY_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(KeyError))
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
|
# define E_FLOATDOMAIN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FloatDomainError))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define E_KEY_ERROR (mrb_exc_get(mrb, "KeyError"))
|
|
||||||
|
|
||||||
MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg);
|
MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg);
|
||||||
MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv);
|
MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv);
|
||||||
MRB_API mrb_value mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c);
|
MRB_API mrb_value mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c);
|
||||||
@@ -1297,7 +1340,7 @@ MRB_API void mrb_gc_register(mrb_state *mrb, mrb_value obj);
|
|||||||
MRB_API void mrb_gc_unregister(mrb_state *mrb, mrb_value obj);
|
MRB_API void mrb_gc_unregister(mrb_state *mrb, mrb_value obj);
|
||||||
|
|
||||||
MRB_API mrb_value mrb_to_int(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_to_int(mrb_state *mrb, mrb_value val);
|
||||||
#define mrb_int(mrb, val) mrb_fixnum(mrb_to_int(mrb, val))
|
#define mrb_int(mrb, val) mrb_integer(mrb_to_int(mrb, val))
|
||||||
/* string type checking (contrary to the name, it doesn't convert) */
|
/* string type checking (contrary to the name, it doesn't convert) */
|
||||||
MRB_API mrb_value mrb_to_str(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_to_str(mrb_state *mrb, mrb_value val);
|
||||||
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
|
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
|
||||||
@@ -1307,14 +1350,8 @@ MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)
|
|||||||
if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
|
if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum call_type {
|
|
||||||
CALL_PUBLIC,
|
|
||||||
CALL_FCALL,
|
|
||||||
CALL_VCALL,
|
|
||||||
CALL_TYPE_MAX
|
|
||||||
} call_type;
|
|
||||||
|
|
||||||
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *c, const char *a, const char *b);
|
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *c, const char *a, const char *b);
|
||||||
|
MRB_API void mrb_define_alias_id(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
|
||||||
MRB_API const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
|
MRB_API const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
|
||||||
MRB_API void mrb_define_global_const(mrb_state *mrb, const char *name, mrb_value val);
|
MRB_API void mrb_define_global_const(mrb_state *mrb, const char *name, mrb_value val);
|
||||||
|
|
||||||
@@ -1351,7 +1388,7 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
|
|||||||
*
|
*
|
||||||
* Implemented in mruby-fiber
|
* Implemented in mruby-fiber
|
||||||
*/
|
*/
|
||||||
#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
|
#define E_FIBER_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError))
|
||||||
MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
|
MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
|
||||||
|
|
||||||
/* memory pool implementation */
|
/* memory pool implementation */
|
||||||
@@ -1371,6 +1408,10 @@ MRB_API void mrb_show_copyright(mrb_state *mrb);
|
|||||||
|
|
||||||
MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...);
|
MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...);
|
||||||
|
|
||||||
|
#ifdef MRB_PRESYM_SCANNING
|
||||||
|
# include <mruby/presym/scanning.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* memcpy and memset does not work with gdb reverse-next on my box */
|
/* memcpy and memset does not work with gdb reverse-next on my box */
|
||||||
/* use naive memcpy and memset instead */
|
/* use naive memcpy and memset instead */
|
||||||
|
|||||||
+23
-6
@@ -21,7 +21,14 @@ typedef struct mrb_shared_array {
|
|||||||
mrb_value *ptr;
|
mrb_value *ptr;
|
||||||
} mrb_shared_array;
|
} mrb_shared_array;
|
||||||
|
|
||||||
#define MRB_ARY_EMBED_LEN_MAX ((mrb_int)(sizeof(void*)*3/sizeof(mrb_value)))
|
#if defined(MRB_32BIT) && defined(MRB_NO_BOXING)
|
||||||
|
# define MRB_ARY_NO_EMBED
|
||||||
|
# define MRB_ARY_EMBED_LEN_MAX 0
|
||||||
|
#else
|
||||||
|
# define MRB_ARY_EMBED_LEN_MAX ((mrb_int)(sizeof(void*)*3/sizeof(mrb_value)))
|
||||||
|
mrb_static_assert(MRB_ARY_EMBED_LEN_MAX > 0, "MRB_ARY_EMBED_LEN_MAX > 0");
|
||||||
|
#endif
|
||||||
|
|
||||||
struct RArray {
|
struct RArray {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
union {
|
union {
|
||||||
@@ -33,7 +40,9 @@ struct RArray {
|
|||||||
} aux;
|
} aux;
|
||||||
mrb_value *ptr;
|
mrb_value *ptr;
|
||||||
} heap;
|
} heap;
|
||||||
void *ary[3];
|
#ifndef MRB_ARY_NO_EMBED
|
||||||
|
mrb_value ary[MRB_ARY_EMBED_LEN_MAX];
|
||||||
|
#endif
|
||||||
} as;
|
} as;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,12 +50,20 @@ struct RArray {
|
|||||||
#define mrb_ary_value(p) mrb_obj_value((void*)(p))
|
#define mrb_ary_value(p) mrb_obj_value((void*)(p))
|
||||||
#define RARRAY(v) ((struct RArray*)(mrb_ptr(v)))
|
#define RARRAY(v) ((struct RArray*)(mrb_ptr(v)))
|
||||||
|
|
||||||
|
#ifdef MRB_ARY_NO_EMBED
|
||||||
|
#define ARY_EMBED_P(a) 0
|
||||||
|
#define ARY_UNSET_EMBED_FLAG(a) (void)0
|
||||||
|
#define ARY_EMBED_LEN(a) 0
|
||||||
|
#define ARY_SET_EMBED_LEN(a,len) (void)0
|
||||||
|
#define ARY_EMBED_PTR(a) 0
|
||||||
|
#else
|
||||||
#define MRB_ARY_EMBED_MASK 7
|
#define MRB_ARY_EMBED_MASK 7
|
||||||
#define ARY_EMBED_P(a) ((a)->flags & MRB_ARY_EMBED_MASK)
|
#define ARY_EMBED_P(a) ((a)->flags & MRB_ARY_EMBED_MASK)
|
||||||
#define ARY_UNSET_EMBED_FLAG(a) ((a)->flags &= ~(MRB_ARY_EMBED_MASK))
|
#define ARY_UNSET_EMBED_FLAG(a) ((a)->flags &= ~(MRB_ARY_EMBED_MASK))
|
||||||
#define ARY_EMBED_LEN(a) ((mrb_int)(((a)->flags & MRB_ARY_EMBED_MASK) - 1))
|
#define ARY_EMBED_LEN(a) ((mrb_int)(((a)->flags & MRB_ARY_EMBED_MASK) - 1))
|
||||||
#define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1))
|
#define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1))
|
||||||
#define ARY_EMBED_PTR(a) ((mrb_value*)(&(a)->as.ary))
|
#define ARY_EMBED_PTR(a) ((a)->as.ary)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len)
|
#define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len)
|
||||||
#define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr)
|
#define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr)
|
||||||
@@ -232,10 +249,10 @@ MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
|
|||||||
*
|
*
|
||||||
* Equivalent to:
|
* Equivalent to:
|
||||||
*
|
*
|
||||||
* ary.shift
|
* ary[head, len] = rpl
|
||||||
*
|
*
|
||||||
* @param mrb The mruby state reference.
|
* @param mrb The mruby state reference.
|
||||||
* @param self The array from which the value will be shifted.
|
* @param self The array from which the value will be partiality replaced.
|
||||||
* @param head Beginning position of a replacement subsequence.
|
* @param head Beginning position of a replacement subsequence.
|
||||||
* @param len Length of a replacement subsequence.
|
* @param len Length of a replacement subsequence.
|
||||||
* @param rpl The array of replacement elements.
|
* @param rpl The array of replacement elements.
|
||||||
@@ -279,7 +296,7 @@ MRB_API mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
|
|||||||
*
|
*
|
||||||
* @param mrb The mruby state reference.
|
* @param mrb The mruby state reference.
|
||||||
* @param ary The target array
|
* @param ary The target array
|
||||||
* @param sep The separater, can be NULL
|
* @param sep The separator, can be NULL
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
|
MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
|
||||||
|
|
||||||
|
|||||||
+74
-49
@@ -7,12 +7,12 @@
|
|||||||
#ifndef MRUBY_BOXING_NAN_H
|
#ifndef MRUBY_BOXING_NAN_H
|
||||||
#define MRUBY_BOXING_NAN_H
|
#define MRUBY_BOXING_NAN_H
|
||||||
|
|
||||||
#ifdef MRB_USE_FLOAT
|
#ifdef MRB_USE_FLOAT32
|
||||||
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT conflict <<----
|
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT32 conflict <<----
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_WITHOUT_FLOAT
|
#ifdef MRB_NO_FLOAT
|
||||||
# error ---->> MRB_NAN_BOXING and MRB_WITHOUT_FLOAT conflict <<----
|
# error ---->> MRB_NAN_BOXING and MRB_NO_FLOAT conflict <<----
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MRB_INT64
|
#ifdef MRB_INT64
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#define MRB_FIXNUM_SHIFT 0
|
#define MRB_FIXNUM_SHIFT 0
|
||||||
#define MRB_SYMBOL_SHIFT 0
|
#define MRB_SYMBOL_SHIFT 0
|
||||||
|
#define MRB_FIXNUM_MIN INT32_MIN
|
||||||
|
#define MRB_FIXNUM_MAX INT32_MAX
|
||||||
|
|
||||||
/* value representation by nan-boxing:
|
/* value representation by nan-boxing:
|
||||||
* float : FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
|
* float : FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
|
||||||
@@ -31,75 +33,98 @@
|
|||||||
* in the right direction. Also, TTTTTT is the mrb_vtype + 1;
|
* in the right direction. Also, TTTTTT is the mrb_vtype + 1;
|
||||||
*/
|
*/
|
||||||
typedef struct mrb_value {
|
typedef struct mrb_value {
|
||||||
union {
|
uint64_t u;
|
||||||
mrb_float f;
|
|
||||||
union {
|
|
||||||
void *p;
|
|
||||||
struct {
|
|
||||||
MRB_ENDIAN_LOHI(
|
|
||||||
uint32_t ttt;
|
|
||||||
,union {
|
|
||||||
mrb_int i;
|
|
||||||
mrb_sym sym;
|
|
||||||
};
|
|
||||||
)
|
|
||||||
};
|
|
||||||
#ifdef MRB_64BIT
|
|
||||||
struct RCptr *vp;
|
|
||||||
#endif
|
|
||||||
} value;
|
|
||||||
};
|
|
||||||
} mrb_value;
|
} mrb_value;
|
||||||
|
|
||||||
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
|
union mrb_value_ {
|
||||||
|
mrb_float f;
|
||||||
|
uint64_t u;
|
||||||
|
#ifdef MRB_64BIT
|
||||||
|
void *p;
|
||||||
|
# define BOXNAN_IMMEDIATE_VALUE uint32_t i
|
||||||
|
#else
|
||||||
|
# define BOXNAN_IMMEDIATE_VALUE union { uint32_t i; void *p; }
|
||||||
|
#endif
|
||||||
|
struct {
|
||||||
|
MRB_ENDIAN_LOHI(
|
||||||
|
uint32_t ttt;
|
||||||
|
,BOXNAN_IMMEDIATE_VALUE;
|
||||||
|
)
|
||||||
|
};
|
||||||
|
mrb_value value;
|
||||||
|
};
|
||||||
|
|
||||||
#define mrb_tt(o) ((enum mrb_vtype)(((o).value.ttt & 0xfc000)>>14)-1)
|
mrb_static_assert1(sizeof(mrb_value) == sizeof(union mrb_value_));
|
||||||
#define mrb_type(o) (enum mrb_vtype)((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)
|
|
||||||
#define mrb_ptr(o) ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2))
|
static inline union mrb_value_
|
||||||
#define mrb_float(o) (o).f
|
mrb_val_union(mrb_value v)
|
||||||
#define mrb_fixnum(o) (o).value.i
|
{
|
||||||
#define mrb_symbol(o) (o).value.sym
|
union mrb_value_ x;
|
||||||
|
x.value = v;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define mrb_tt(o) ((enum mrb_vtype)((mrb_val_union(o).ttt & 0xfc000)>>14)-1)
|
||||||
|
#define mrb_type(o) (enum mrb_vtype)((uint32_t)0xfff00000 < mrb_val_union(o).ttt ? mrb_tt(o) : MRB_TT_FLOAT)
|
||||||
|
#define mrb_float(o) mrb_val_union(o).f
|
||||||
|
#define mrb_fixnum(o) ((mrb_int)mrb_val_union(o).i)
|
||||||
|
#define mrb_integer(o) mrb_fixnum(o)
|
||||||
|
#define mrb_symbol(o) ((mrb_sym)mrb_val_union(o).i)
|
||||||
|
|
||||||
#ifdef MRB_64BIT
|
#ifdef MRB_64BIT
|
||||||
MRB_API mrb_value mrb_nan_boxing_cptr_value(struct mrb_state*, void*);
|
#define mrb_ptr(o) ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)(mrb_val_union(o).p)))<<2))
|
||||||
#define mrb_cptr(o) (((struct RCptr*)mrb_ptr(o))->p)
|
#define mrb_cptr(o) (((struct RCptr*)mrb_ptr(o))->p)
|
||||||
#define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff)
|
#define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff)
|
||||||
#else
|
#else
|
||||||
#define mrb_cptr(o) ((o).value.p)
|
#define mrb_ptr(o) ((void*)mrb_val_union(o).i)
|
||||||
|
#define mrb_cptr(o) mrb_ptr(o)
|
||||||
#define BOXNAN_SHIFT_LONG_POINTER(v) 0
|
#define BOXNAN_SHIFT_LONG_POINTER(v) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BOXNAN_SET_VALUE(o, tt, attr, v) do {\
|
#define BOXNAN_SET_VALUE(o, tt, attr, v) do { \
|
||||||
(o).attr = (v);\
|
union mrb_value_ mrb_value_union_variable; \
|
||||||
(o).value.ttt = 0xfff00000 | (((tt)+1)<<14);\
|
mrb_value_union_variable.attr = (v);\
|
||||||
|
mrb_value_union_variable.ttt = 0xfff00000 | (((tt)+1)<<14);\
|
||||||
|
o = mrb_value_union_variable.value;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#ifdef MRB_64BIT
|
||||||
#define BOXNAN_SET_OBJ_VALUE(o, tt, v) do {\
|
#define BOXNAN_SET_OBJ_VALUE(o, tt, v) do {\
|
||||||
(o).value.p = (void*)((uintptr_t)(v)>>2);\
|
union mrb_value_ mrb_value_union_variable;\
|
||||||
(o).value.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
|
mrb_value_union_variable.p = (void*)((uintptr_t)(v)>>2);\
|
||||||
|
mrb_value_union_variable.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
|
||||||
|
o = mrb_value_union_variable.value;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define BOXNAN_SET_OBJ_VALUE(o, tt, v) BOXNAN_SET_VALUE(o, tt, i, (uint32_t)v)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SET_FLOAT_VALUE(mrb,r,v) do { \
|
#define SET_FLOAT_VALUE(mrb,r,v) do { \
|
||||||
if ((v) != (v)) { \
|
union mrb_value_ mrb_value_union_variable; \
|
||||||
(r).value.ttt = 0x7ff80000; \
|
if ((v) != (v)) { /* NaN */ \
|
||||||
(r).value.i = 0; \
|
mrb_value_union_variable.ttt = 0x7ff80000; \
|
||||||
|
mrb_value_union_variable.i = 0; \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
(r).f = v; \
|
mrb_value_union_variable.f = (v); \
|
||||||
}} while(0)
|
} \
|
||||||
|
r = mrb_value_union_variable.value; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define SET_NIL_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
|
#define SET_NIL_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, i, 0)
|
||||||
#define SET_FALSE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
|
#define SET_FALSE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, i, 1)
|
||||||
#define SET_TRUE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
|
#define SET_TRUE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_TRUE, i, 1)
|
||||||
#define SET_BOOL_VALUE(r,b) BOXNAN_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
|
#define SET_BOOL_VALUE(r,b) BOXNAN_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, i, 1)
|
||||||
#define SET_INT_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
|
#define SET_INT_VALUE(mrb, r,n) BOXNAN_SET_VALUE(r, MRB_TT_INTEGER, i, (uint32_t)(n))
|
||||||
#define SET_SYM_VALUE(r,v) BOXNAN_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
|
#define SET_FIXNUM_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_INTEGER, i, (uint32_t)(n))
|
||||||
|
#define SET_SYM_VALUE(r,v) BOXNAN_SET_VALUE(r, MRB_TT_SYMBOL, i, (uint32_t)(v))
|
||||||
#define SET_OBJ_VALUE(r,v) BOXNAN_SET_OBJ_VALUE(r, (((struct RObject*)(v))->tt), (v))
|
#define SET_OBJ_VALUE(r,v) BOXNAN_SET_OBJ_VALUE(r, (((struct RObject*)(v))->tt), (v))
|
||||||
#ifdef MRB_64BIT
|
#ifdef MRB_64BIT
|
||||||
|
MRB_API mrb_value mrb_nan_boxing_cptr_value(struct mrb_state*, void*);
|
||||||
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_nan_boxing_cptr_value(mrb, v))
|
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_nan_boxing_cptr_value(mrb, v))
|
||||||
#else
|
#else
|
||||||
#define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
|
#define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_VALUE(r, MRB_TT_CPTR, p, v)
|
||||||
#endif
|
#endif
|
||||||
#define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
|
#define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, i, 0)
|
||||||
|
|
||||||
#endif /* MRUBY_BOXING_NAN_H */
|
#endif /* MRUBY_BOXING_NAN_H */
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
|
|
||||||
#define MRB_FIXNUM_SHIFT 0
|
#define MRB_FIXNUM_SHIFT 0
|
||||||
#define MRB_SYMBOL_SHIFT 0
|
#define MRB_SYMBOL_SHIFT 0
|
||||||
|
#define MRB_FIXNUM_MIN MRB_INT_MIN
|
||||||
|
#define MRB_FIXNUM_MAX MRB_INT_MAX
|
||||||
|
|
||||||
union mrb_value_union {
|
union mrb_value_union {
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
mrb_float f;
|
mrb_float f;
|
||||||
#endif
|
#endif
|
||||||
void *p;
|
void *p;
|
||||||
@@ -24,16 +26,13 @@ typedef struct mrb_value {
|
|||||||
enum mrb_vtype tt;
|
enum mrb_vtype tt;
|
||||||
} mrb_value;
|
} mrb_value;
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
|
||||||
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define mrb_ptr(o) (o).value.p
|
#define mrb_ptr(o) (o).value.p
|
||||||
#define mrb_cptr(o) mrb_ptr(o)
|
#define mrb_cptr(o) mrb_ptr(o)
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#define mrb_float(o) (o).value.f
|
#define mrb_float(o) (o).value.f
|
||||||
#endif
|
#endif
|
||||||
#define mrb_fixnum(o) (o).value.i
|
#define mrb_fixnum(o) (o).value.i
|
||||||
|
#define mrb_integer(o) mrb_fixnum(o)
|
||||||
#define mrb_symbol(o) (o).value.sym
|
#define mrb_symbol(o) (o).value.sym
|
||||||
#define mrb_type(o) (o).tt
|
#define mrb_type(o) (o).tt
|
||||||
|
|
||||||
@@ -46,8 +45,9 @@ typedef struct mrb_value {
|
|||||||
#define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
|
#define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
|
||||||
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
|
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
|
||||||
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
|
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
|
||||||
#define SET_INT_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
|
#define SET_INT_VALUE(mrb,r,n) BOXNIX_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#define SET_FIXNUM_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
|
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
|
||||||
#endif
|
#endif
|
||||||
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
|
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
|
||||||
|
|||||||
+88
-57
@@ -7,17 +7,18 @@
|
|||||||
#ifndef MRUBY_BOXING_WORD_H
|
#ifndef MRUBY_BOXING_WORD_H
|
||||||
#define MRUBY_BOXING_WORD_H
|
#define MRUBY_BOXING_WORD_H
|
||||||
|
|
||||||
#if defined(MRB_INT64) && !defined(MRB_64BIT)
|
#ifndef MRB_NO_FLOAT
|
||||||
#error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
|
||||||
struct RFloat {
|
struct RFloat {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
mrb_float f;
|
mrb_float f;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct RInteger {
|
||||||
|
MRB_OBJECT_HEADER;
|
||||||
|
mrb_int i;
|
||||||
|
};
|
||||||
|
|
||||||
enum mrb_special_consts {
|
enum mrb_special_consts {
|
||||||
MRB_Qnil = 0,
|
MRB_Qnil = 0,
|
||||||
MRB_Qfalse = 4,
|
MRB_Qfalse = 4,
|
||||||
@@ -32,6 +33,14 @@ enum mrb_special_consts {
|
|||||||
#endif
|
#endif
|
||||||
#define MRB_SYMBOL_SHIFT BOXWORD_SYMBOL_SHIFT
|
#define MRB_SYMBOL_SHIFT BOXWORD_SYMBOL_SHIFT
|
||||||
|
|
||||||
|
#if defined(MRB_64BIT) && defined(MRB_INT64)
|
||||||
|
# define MRB_FIXNUM_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
|
||||||
|
# define MRB_FIXNUM_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
|
||||||
|
#else
|
||||||
|
# define MRB_FIXNUM_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
|
||||||
|
# define MRB_FIXNUM_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BOXWORD_FIXNUM_BIT_POS 1
|
#define BOXWORD_FIXNUM_BIT_POS 1
|
||||||
#define BOXWORD_SYMBOL_BIT_POS 2
|
#define BOXWORD_SYMBOL_BIT_POS 2
|
||||||
#define BOXWORD_FIXNUM_SHIFT BOXWORD_FIXNUM_BIT_POS
|
#define BOXWORD_FIXNUM_SHIFT BOXWORD_FIXNUM_BIT_POS
|
||||||
@@ -46,14 +55,12 @@ enum mrb_special_consts {
|
|||||||
#define BOXWORD_SYMBOL_MASK ((1 << BOXWORD_SYMBOL_BIT_POS) - 1)
|
#define BOXWORD_SYMBOL_MASK ((1 << BOXWORD_SYMBOL_BIT_POS) - 1)
|
||||||
#define BOXWORD_IMMEDIATE_MASK 0x07
|
#define BOXWORD_IMMEDIATE_MASK 0x07
|
||||||
|
|
||||||
#define BOXWORD_SHIFT_VALUE(o,n,t) \
|
|
||||||
(t)(((long)(o).w) >> BOXWORD_##n##_SHIFT)
|
|
||||||
#define BOXWORD_SET_SHIFT_VALUE(o,n,v) \
|
#define BOXWORD_SET_SHIFT_VALUE(o,n,v) \
|
||||||
((o).w = (((unsigned long)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
((o).w = (((uintptr_t)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
||||||
#define BOXWORD_SHIFT_VALUE_P(o,n) \
|
#define BOXWORD_SHIFT_VALUE_P(o,n) \
|
||||||
(((o).w & BOXWORD_##n##_MASK) == BOXWORD_##n##_FLAG)
|
(((o).w & BOXWORD_##n##_MASK) == BOXWORD_##n##_FLAG)
|
||||||
#define BOXWORD_OBJ_TYPE_P(o,n) \
|
#define BOXWORD_OBJ_TYPE_P(o,n) \
|
||||||
(!mrb_immediate_p(o) && (o).value.bp->tt == MRB_TT_##n)
|
(!mrb_immediate_p(o) && mrb_val_union(o).bp->tt == MRB_TT_##n)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mrb_value representation:
|
* mrb_value representation:
|
||||||
@@ -66,54 +73,72 @@ enum mrb_special_consts {
|
|||||||
* symbol: ...SSSS SS10 (use only upper 32-bit as symbol value on 64-bit CPU)
|
* symbol: ...SSSS SS10 (use only upper 32-bit as symbol value on 64-bit CPU)
|
||||||
* object: ...PPPP P000 (any bits are 1)
|
* object: ...PPPP P000 (any bits are 1)
|
||||||
*/
|
*/
|
||||||
typedef union mrb_value {
|
typedef struct mrb_value {
|
||||||
union {
|
uintptr_t w;
|
||||||
void *p;
|
|
||||||
#ifdef MRB_64BIT
|
|
||||||
/* use struct to avoid bit shift. */
|
|
||||||
struct {
|
|
||||||
MRB_ENDIAN_LOHI(
|
|
||||||
mrb_sym sym;
|
|
||||||
,uint32_t sym_flag;
|
|
||||||
)
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
struct RBasic *bp;
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
|
||||||
struct RFloat *fp;
|
|
||||||
#endif
|
|
||||||
struct RCptr *vp;
|
|
||||||
} value;
|
|
||||||
unsigned long w;
|
|
||||||
} mrb_value;
|
} mrb_value;
|
||||||
|
|
||||||
MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
|
union mrb_value_ {
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
void *p;
|
||||||
MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
|
|
||||||
MRB_API mrb_value mrb_word_boxing_float_pool(struct mrb_state*, mrb_float);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
|
||||||
#define mrb_float_pool(mrb,f) mrb_word_boxing_float_pool(mrb,f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define mrb_ptr(o) (o).value.p
|
|
||||||
#define mrb_cptr(o) (o).value.vp->p
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
|
||||||
#define mrb_float(o) (o).value.fp->f
|
|
||||||
#endif
|
|
||||||
#define mrb_fixnum(o) BOXWORD_SHIFT_VALUE(o, FIXNUM, mrb_int)
|
|
||||||
#ifdef MRB_64BIT
|
#ifdef MRB_64BIT
|
||||||
#define mrb_symbol(o) (o).value.sym
|
/* use struct to avoid bit shift. */
|
||||||
#else
|
struct {
|
||||||
#define mrb_symbol(o) BOXWORD_SHIFT_VALUE(o, SYMBOL, mrb_sym)
|
MRB_ENDIAN_LOHI(
|
||||||
|
mrb_sym sym;
|
||||||
|
,uint32_t sym_flag;
|
||||||
|
)
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
#define mrb_bool(o) (((o).w & ~(unsigned long)MRB_Qfalse) != 0)
|
struct RBasic *bp;
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
|
struct RFloat *fp;
|
||||||
|
#endif
|
||||||
|
struct RInteger *ip;
|
||||||
|
struct RCptr *vp;
|
||||||
|
uintptr_t w;
|
||||||
|
mrb_value value;
|
||||||
|
};
|
||||||
|
|
||||||
|
mrb_static_assert1(sizeof(mrb_value) == sizeof(union mrb_value_));
|
||||||
|
|
||||||
|
static inline union mrb_value_
|
||||||
|
mrb_val_union(mrb_value v)
|
||||||
|
{
|
||||||
|
union mrb_value_ x;
|
||||||
|
x.value = v;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
|
MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
|
||||||
|
#endif
|
||||||
|
MRB_API mrb_value mrb_word_boxing_int_value(struct mrb_state*, mrb_int);
|
||||||
|
|
||||||
#define mrb_immediate_p(o) ((o).w & BOXWORD_IMMEDIATE_MASK || (o).w == MRB_Qnil)
|
#define mrb_immediate_p(o) ((o).w & BOXWORD_IMMEDIATE_MASK || (o).w == MRB_Qnil)
|
||||||
#define mrb_fixnum_p(o) BOXWORD_SHIFT_VALUE_P(o, FIXNUM)
|
|
||||||
|
#define mrb_ptr(o) mrb_val_union(o).p
|
||||||
|
#define mrb_cptr(o) mrb_val_union(o).vp->p
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
|
#define mrb_float(o) mrb_val_union(o).fp->f
|
||||||
|
#endif
|
||||||
|
#define mrb_fixnum(o) (mrb_int)(((intptr_t)(o).w) >> BOXWORD_FIXNUM_SHIFT)
|
||||||
|
MRB_INLINE mrb_int
|
||||||
|
mrb_integer_func(mrb_value o) {
|
||||||
|
if (mrb_immediate_p(o)) return mrb_fixnum(o);
|
||||||
|
return mrb_val_union(o).ip->i;
|
||||||
|
}
|
||||||
|
#define mrb_integer(o) mrb_integer_func(o)
|
||||||
#ifdef MRB_64BIT
|
#ifdef MRB_64BIT
|
||||||
#define mrb_symbol_p(o) ((o).value.sym_flag == BOXWORD_SYMBOL_FLAG)
|
#define mrb_symbol(o) mrb_val_union(o).sym
|
||||||
|
#else
|
||||||
|
#define mrb_symbol(o) (mrb_sym)(((o).w) >> BOXWORD_SYMBOL_SHIFT)
|
||||||
|
#endif
|
||||||
|
#define mrb_bool(o) (((o).w & ~(uintptr_t)MRB_Qfalse) != 0)
|
||||||
|
|
||||||
|
#define mrb_fixnum_p(o) BOXWORD_SHIFT_VALUE_P(o, FIXNUM)
|
||||||
|
#define mrb_integer_p(o) (BOXWORD_SHIFT_VALUE_P(o, FIXNUM)||BOXWORD_OBJ_TYPE_P(o, INTEGER))
|
||||||
|
#ifdef MRB_64BIT
|
||||||
|
#define mrb_symbol_p(o) (mrb_val_union(o).sym_flag == BOXWORD_SYMBOL_FLAG)
|
||||||
#else
|
#else
|
||||||
#define mrb_symbol_p(o) BOXWORD_SHIFT_VALUE_P(o, SYMBOL)
|
#define mrb_symbol_p(o) BOXWORD_SHIFT_VALUE_P(o, SYMBOL)
|
||||||
#endif
|
#endif
|
||||||
@@ -121,7 +146,7 @@ MRB_API mrb_value mrb_word_boxing_float_pool(struct mrb_state*, mrb_float);
|
|||||||
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
|
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
|
||||||
#define mrb_false_p(o) ((o).w == MRB_Qfalse)
|
#define mrb_false_p(o) ((o).w == MRB_Qfalse)
|
||||||
#define mrb_true_p(o) ((o).w == MRB_Qtrue)
|
#define mrb_true_p(o) ((o).w == MRB_Qtrue)
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#define mrb_float_p(o) BOXWORD_OBJ_TYPE_P(o, FLOAT)
|
#define mrb_float_p(o) BOXWORD_OBJ_TYPE_P(o, FLOAT)
|
||||||
#endif
|
#endif
|
||||||
#define mrb_array_p(o) BOXWORD_OBJ_TYPE_P(o, ARRAY)
|
#define mrb_array_p(o) BOXWORD_OBJ_TYPE_P(o, ARRAY)
|
||||||
@@ -143,7 +168,7 @@ MRB_API mrb_value mrb_word_boxing_float_pool(struct mrb_state*, mrb_float);
|
|||||||
#define mrb_istruct_p(o) BOXWORD_OBJ_TYPE_P(o, ISTRUCT)
|
#define mrb_istruct_p(o) BOXWORD_OBJ_TYPE_P(o, ISTRUCT)
|
||||||
#define mrb_break_p(o) BOXWORD_OBJ_TYPE_P(o, BREAK)
|
#define mrb_break_p(o) BOXWORD_OBJ_TYPE_P(o, BREAK)
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#define SET_FLOAT_VALUE(mrb,r,v) ((r) = mrb_word_boxing_float_value(mrb, v))
|
#define SET_FLOAT_VALUE(mrb,r,v) ((r) = mrb_word_boxing_float_value(mrb, v))
|
||||||
#endif
|
#endif
|
||||||
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_word_boxing_cptr_value(mrb, v))
|
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_word_boxing_cptr_value(mrb, v))
|
||||||
@@ -152,23 +177,29 @@ MRB_API mrb_value mrb_word_boxing_float_pool(struct mrb_state*, mrb_float);
|
|||||||
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
|
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
|
||||||
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
|
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
|
||||||
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
|
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
|
||||||
#define SET_INT_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, FIXNUM, n)
|
#define SET_INT_VALUE(mrb,r,n) ((r) = mrb_word_boxing_int_value(mrb, n))
|
||||||
|
#define SET_FIXNUM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, FIXNUM, n)
|
||||||
#ifdef MRB_64BIT
|
#ifdef MRB_64BIT
|
||||||
#define SET_SYM_VALUE(r,v) ((r).value.sym = v, (r).value.sym_flag = BOXWORD_SYMBOL_FLAG)
|
#define SET_SYM_VALUE(r,v) do {\
|
||||||
|
union mrb_value_ mrb_value_union_variable;\
|
||||||
|
mrb_value_union_variable.sym = v;\
|
||||||
|
mrb_value_union_variable.sym_flag = BOXWORD_SYMBOL_FLAG;\
|
||||||
|
(r) = mrb_value_union_variable.value;\
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define SET_SYM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, SYMBOL, n)
|
#define SET_SYM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, SYMBOL, n)
|
||||||
#endif
|
#endif
|
||||||
#define SET_OBJ_VALUE(r,v) ((r).value.p = v)
|
#define SET_OBJ_VALUE(r,v) ((r).w = (uintptr_t)(v))
|
||||||
|
|
||||||
MRB_INLINE enum mrb_vtype
|
MRB_INLINE enum mrb_vtype
|
||||||
mrb_type(mrb_value o)
|
mrb_type(mrb_value o)
|
||||||
{
|
{
|
||||||
return !mrb_bool(o) ? MRB_TT_FALSE :
|
return !mrb_bool(o) ? MRB_TT_FALSE :
|
||||||
mrb_true_p(o) ? MRB_TT_TRUE :
|
mrb_true_p(o) ? MRB_TT_TRUE :
|
||||||
mrb_fixnum_p(o) ? MRB_TT_FIXNUM :
|
mrb_fixnum_p(o) ? MRB_TT_INTEGER :
|
||||||
mrb_symbol_p(o) ? MRB_TT_SYMBOL :
|
mrb_symbol_p(o) ? MRB_TT_SYMBOL :
|
||||||
mrb_undef_p(o) ? MRB_TT_UNDEF :
|
mrb_undef_p(o) ? MRB_TT_UNDEF :
|
||||||
o.value.bp->tt;
|
mrb_val_union(o).bp->tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MRUBY_BOXING_WORD_H */
|
#endif /* MRUBY_BOXING_WORD_H */
|
||||||
|
|||||||
+10
-8
@@ -17,7 +17,7 @@ MRB_BEGIN_DECL
|
|||||||
struct RClass {
|
struct RClass {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
struct iv_tbl *iv;
|
struct iv_tbl *iv;
|
||||||
struct kh_mt *mt;
|
struct mt_tbl *mt;
|
||||||
struct RClass *super;
|
struct RClass *super;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,9 +35,9 @@ mrb_class(mrb_state *mrb, mrb_value v)
|
|||||||
return mrb->true_class;
|
return mrb->true_class;
|
||||||
case MRB_TT_SYMBOL:
|
case MRB_TT_SYMBOL:
|
||||||
return mrb->symbol_class;
|
return mrb->symbol_class;
|
||||||
case MRB_TT_FIXNUM:
|
case MRB_TT_INTEGER:
|
||||||
return mrb->fixnum_class;
|
return mrb->integer_class;
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
case MRB_TT_FLOAT:
|
case MRB_TT_FLOAT:
|
||||||
return mrb->float_class;
|
return mrb->float_class;
|
||||||
#endif
|
#endif
|
||||||
@@ -73,13 +73,11 @@ mrb_class(mrb_state *mrb, mrb_value v)
|
|||||||
#define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
|
#define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
|
||||||
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
|
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
|
||||||
|
|
||||||
MRB_API struct RClass* mrb_define_class_id(mrb_state*, mrb_sym, struct RClass*);
|
|
||||||
MRB_API struct RClass* mrb_define_module_id(mrb_state*, mrb_sym);
|
|
||||||
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
|
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
|
||||||
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
|
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
|
||||||
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
|
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
|
||||||
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
|
|
||||||
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
|
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
|
||||||
|
MRB_API void mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym sym);
|
||||||
|
|
||||||
MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
|
MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
|
||||||
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
|
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
|
||||||
@@ -95,12 +93,16 @@ void mrb_gc_mark_mt(mrb_state*, struct RClass*);
|
|||||||
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
|
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
|
||||||
void mrb_gc_free_mt(mrb_state*, struct RClass*);
|
void mrb_gc_free_mt(mrb_state*, struct RClass*);
|
||||||
|
|
||||||
#ifdef MRB_METHOD_CACHE
|
#ifndef MRB_NO_METHOD_CACHE
|
||||||
void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c);
|
void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c);
|
||||||
#else
|
#else
|
||||||
#define mrb_mc_clear_by_class(mrb,c)
|
#define mrb_mc_clear_by_class(mrb,c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* return non zero to break the loop */
|
||||||
|
typedef int (mrb_mt_foreach_func)(mrb_state*,mrb_sym,mrb_method_t,void*);
|
||||||
|
MRB_API void mrb_mt_foreach(mrb_state*, struct RClass*, mrb_mt_foreach_func*, void*);
|
||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|
||||||
#endif /* MRUBY_CLASS_H */
|
#endif /* MRUBY_CLASS_H */
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#ifdef MRB_ENABLE_CXX_ABI
|
#ifdef MRB_USE_CXX_ABI
|
||||||
#define MRB_BEGIN_DECL
|
#define MRB_BEGIN_DECL
|
||||||
#define MRB_END_DECL
|
#define MRB_END_DECL
|
||||||
#else
|
#else
|
||||||
@@ -82,6 +82,9 @@ MRB_BEGIN_DECL
|
|||||||
# elif defined(__MINGW32_MAJOR_VERSION)
|
# elif defined(__MINGW32_MAJOR_VERSION)
|
||||||
# define MRB_MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 1000 + __MINGW32_MINOR_VERSION)
|
# define MRB_MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 1000 + __MINGW32_MINOR_VERSION)
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(__MINGW32__) && !defined(__MINGW64__)
|
||||||
|
# define MRB_MINGW32_LEGACY
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|||||||
+13
-7
@@ -33,7 +33,7 @@ typedef struct mrbc_context {
|
|||||||
mrb_bool no_exec:1;
|
mrb_bool no_exec:1;
|
||||||
mrb_bool keep_lv:1;
|
mrb_bool keep_lv:1;
|
||||||
mrb_bool no_optimize:1;
|
mrb_bool no_optimize:1;
|
||||||
struct RProc *upper;
|
const struct RProc *upper;
|
||||||
|
|
||||||
size_t parser_nerr;
|
size_t parser_nerr;
|
||||||
} mrbc_context;
|
} mrbc_context;
|
||||||
@@ -42,6 +42,7 @@ MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
|
|||||||
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
|
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
|
||||||
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
|
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
|
||||||
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
|
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
|
||||||
|
MRB_API void mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c);
|
||||||
|
|
||||||
/* AST node structure */
|
/* AST node structure */
|
||||||
typedef struct mrb_ast_node {
|
typedef struct mrb_ast_node {
|
||||||
@@ -98,6 +99,9 @@ enum mrb_string_type {
|
|||||||
/* heredoc structure */
|
/* heredoc structure */
|
||||||
struct mrb_parser_heredoc_info {
|
struct mrb_parser_heredoc_info {
|
||||||
mrb_bool allow_indent:1;
|
mrb_bool allow_indent:1;
|
||||||
|
mrb_bool remove_indent:1;
|
||||||
|
size_t indent;
|
||||||
|
mrb_ast_node *indented;
|
||||||
mrb_bool line_head:1;
|
mrb_bool line_head:1;
|
||||||
enum mrb_string_type type;
|
enum mrb_string_type type;
|
||||||
const char *term;
|
const char *term;
|
||||||
@@ -114,7 +118,8 @@ struct mrb_parser_state {
|
|||||||
struct mrb_pool *pool;
|
struct mrb_pool *pool;
|
||||||
mrb_ast_node *cells;
|
mrb_ast_node *cells;
|
||||||
const char *s, *send;
|
const char *s, *send;
|
||||||
#ifndef MRB_DISABLE_STDIO
|
#ifndef MRB_NO_STDIO
|
||||||
|
/* If both f and s are non-null, it will be taken preferentially from s until s < send. */
|
||||||
FILE *f;
|
FILE *f;
|
||||||
#endif
|
#endif
|
||||||
mrbc_context *cxt;
|
mrbc_context *cxt;
|
||||||
@@ -152,7 +157,7 @@ struct mrb_parser_state {
|
|||||||
|
|
||||||
mrb_bool no_optimize:1;
|
mrb_bool no_optimize:1;
|
||||||
mrb_bool capture_errors:1;
|
mrb_bool capture_errors:1;
|
||||||
struct RProc *upper;
|
const struct RProc *upper;
|
||||||
struct mrb_parser_message error_buffer[10];
|
struct mrb_parser_message error_buffer[10];
|
||||||
struct mrb_parser_message warn_buffer[10];
|
struct mrb_parser_message warn_buffer[10];
|
||||||
|
|
||||||
@@ -172,7 +177,7 @@ MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
|
|||||||
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
|
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
|
||||||
|
|
||||||
/* utility functions */
|
/* utility functions */
|
||||||
#ifndef MRB_DISABLE_STDIO
|
#ifndef MRB_NO_STDIO
|
||||||
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
|
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
|
||||||
#endif
|
#endif
|
||||||
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
|
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
|
||||||
@@ -180,8 +185,8 @@ MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t
|
|||||||
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
|
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
|
||||||
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
|
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
|
||||||
|
|
||||||
/** program load functions
|
/** program load functions
|
||||||
* Please note! Currently due to interactions with the GC calling these functions will
|
* Please note! Currently due to interactions with the GC calling these functions will
|
||||||
* leak one RProc object per function call.
|
* leak one RProc object per function call.
|
||||||
* To prevent this save the current memory arena before calling and restore the arena
|
* To prevent this save the current memory arena before calling and restore the arena
|
||||||
* right after, like so
|
* right after, like so
|
||||||
@@ -189,9 +194,10 @@ MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc
|
|||||||
* mrb_value status = mrb_load_string(mrb, buffer);
|
* mrb_value status = mrb_load_string(mrb, buffer);
|
||||||
* mrb_gc_arena_restore(mrb, ai);
|
* mrb_gc_arena_restore(mrb, ai);
|
||||||
*/
|
*/
|
||||||
#ifndef MRB_DISABLE_STDIO
|
#ifndef MRB_NO_STDIO
|
||||||
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
|
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
|
||||||
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
|
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
|
||||||
|
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrbc_context *c);
|
||||||
#endif
|
#endif
|
||||||
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
|
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
|
||||||
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
|
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ typedef struct mrb_irep_debug_info {
|
|||||||
* get line from irep's debug info and program counter
|
* get line from irep's debug info and program counter
|
||||||
* @return returns NULL if not found
|
* @return returns NULL if not found
|
||||||
*/
|
*/
|
||||||
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
|
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get line from irep's debug info and program counter
|
* get line from irep's debug info and program counter
|
||||||
* @return returns -1 if not found
|
* @return returns -1 if not found
|
||||||
*/
|
*/
|
||||||
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
|
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
|
||||||
|
|
||||||
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
||||||
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
||||||
|
|||||||
+17
-35
@@ -18,10 +18,11 @@ MRB_BEGIN_DECL
|
|||||||
|
|
||||||
#define DUMP_DEBUG_INFO 1
|
#define DUMP_DEBUG_INFO 1
|
||||||
|
|
||||||
int mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
|
int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
|
||||||
#ifndef MRB_DISABLE_STDIO
|
#ifndef MRB_NO_STDIO
|
||||||
int mrb_dump_irep_binary(mrb_state*, mrb_irep*, uint8_t, FILE*);
|
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
|
||||||
int mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
||||||
|
int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
||||||
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
|
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
|
||||||
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
|
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
|
||||||
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
|
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
|
||||||
@@ -38,21 +39,25 @@ MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
|
|||||||
#define MRB_DUMP_GENERAL_FAILURE (-1)
|
#define MRB_DUMP_GENERAL_FAILURE (-1)
|
||||||
#define MRB_DUMP_WRITE_FAULT (-2)
|
#define MRB_DUMP_WRITE_FAULT (-2)
|
||||||
#define MRB_DUMP_READ_FAULT (-3)
|
#define MRB_DUMP_READ_FAULT (-3)
|
||||||
#define MRB_DUMP_CRC_ERROR (-4)
|
#define MRB_DUMP_INVALID_FILE_HEADER (-4)
|
||||||
#define MRB_DUMP_INVALID_FILE_HEADER (-5)
|
#define MRB_DUMP_INVALID_IREP (-5)
|
||||||
#define MRB_DUMP_INVALID_IREP (-6)
|
#define MRB_DUMP_INVALID_ARGUMENT (-6)
|
||||||
#define MRB_DUMP_INVALID_ARGUMENT (-7)
|
|
||||||
|
|
||||||
/* null symbol length */
|
/* null symbol length */
|
||||||
#define MRB_DUMP_NULL_SYM_LEN 0xFFFF
|
#define MRB_DUMP_NULL_SYM_LEN 0xFFFF
|
||||||
|
|
||||||
/* Rite Binary File header */
|
/* Rite Binary File header */
|
||||||
#define RITE_BINARY_IDENT "RITE"
|
#define RITE_BINARY_IDENT "RITE"
|
||||||
#define RITE_BINARY_FORMAT_VER "0007"
|
/* Binary Format Version Major:Minor */
|
||||||
|
/* Major: Incompatible to prior versions */
|
||||||
|
/* Minor: Upper-compatible to prior versions */
|
||||||
|
#define RITE_BINARY_MAJOR_VER "02"
|
||||||
|
#define RITE_BINARY_MINOR_VER "00"
|
||||||
|
#define RITE_BINARY_FORMAT_VER RITE_BINARY_MAJOR_VER RITE_BINARY_MINOR_VER
|
||||||
#define RITE_COMPILER_NAME "MATZ"
|
#define RITE_COMPILER_NAME "MATZ"
|
||||||
#define RITE_COMPILER_VERSION "0000"
|
#define RITE_COMPILER_VERSION "0000"
|
||||||
|
|
||||||
#define RITE_VM_VER "0002"
|
#define RITE_VM_VER "0300"
|
||||||
|
|
||||||
#define RITE_BINARY_EOF "END\0"
|
#define RITE_BINARY_EOF "END\0"
|
||||||
#define RITE_SECTION_IREP_IDENT "IREP"
|
#define RITE_SECTION_IREP_IDENT "IREP"
|
||||||
@@ -65,8 +70,8 @@ MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
|
|||||||
/* binary header */
|
/* binary header */
|
||||||
struct rite_binary_header {
|
struct rite_binary_header {
|
||||||
uint8_t binary_ident[4]; /* Binary Identifier */
|
uint8_t binary_ident[4]; /* Binary Identifier */
|
||||||
uint8_t binary_version[4]; /* Binary Format Version */
|
uint8_t major_version[2]; /* Binary Format Major Version */
|
||||||
uint8_t binary_crc[2]; /* Binary CRC */
|
uint8_t minor_version[2]; /* Binary Format Minor Version */
|
||||||
uint8_t binary_size[4]; /* Binary Size */
|
uint8_t binary_size[4]; /* Binary Size */
|
||||||
uint8_t compiler_name[4]; /* Compiler name */
|
uint8_t compiler_name[4]; /* Compiler name */
|
||||||
uint8_t compiler_version[4];
|
uint8_t compiler_version[4];
|
||||||
@@ -126,16 +131,6 @@ uint32_to_bin(uint32_t l, uint8_t *bin)
|
|||||||
return sizeof(uint32_t);
|
return sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t
|
|
||||||
uint32l_to_bin(uint32_t l, uint8_t *bin)
|
|
||||||
{
|
|
||||||
bin[3] = (l >> 24) & 0xff;
|
|
||||||
bin[2] = (l >> 16) & 0xff;
|
|
||||||
bin[1] = (l >> 8) & 0xff;
|
|
||||||
bin[0] = l & 0xff;
|
|
||||||
return sizeof(uint32_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
bin_to_uint32(const uint8_t *bin)
|
bin_to_uint32(const uint8_t *bin)
|
||||||
{
|
{
|
||||||
@@ -145,15 +140,6 @@ bin_to_uint32(const uint8_t *bin)
|
|||||||
(uint32_t)bin[3];
|
(uint32_t)bin[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
bin_to_uint32l(const uint8_t *bin)
|
|
||||||
{
|
|
||||||
return (uint32_t)bin[3] << 24 |
|
|
||||||
(uint32_t)bin[2] << 16 |
|
|
||||||
(uint32_t)bin[1] << 8 |
|
|
||||||
(uint32_t)bin[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint16_t
|
static inline uint16_t
|
||||||
bin_to_uint16(const uint8_t *bin)
|
bin_to_uint16(const uint8_t *bin)
|
||||||
{
|
{
|
||||||
@@ -169,8 +155,4 @@ bin_to_uint8(const uint8_t *bin)
|
|||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|
||||||
/** @internal crc.c */
|
|
||||||
uint16_t
|
|
||||||
calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
|
|
||||||
|
|
||||||
#endif /* MRUBY_DUMP_H */
|
#endif /* MRUBY_DUMP_H */
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
** @file mruby/endian.h - detect endian-ness
|
||||||
|
**
|
||||||
|
** See Copyright Notice in mruby.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRUBY_ENDIAN_H
|
||||||
|
#define MRUBY_ENDIAN_H
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
MRB_BEGIN_DECL
|
||||||
|
|
||||||
|
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER__)
|
||||||
|
# define BYTE_ORDER __BYTE_ORDER__
|
||||||
|
#endif
|
||||||
|
#if !defined(BIG_ENDIAN) && defined(__ORDER_BIG_ENDIAN__)
|
||||||
|
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
||||||
|
#endif
|
||||||
|
#if !defined(LITTLE_ENDIAN) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||||
|
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BYTE_ORDER
|
||||||
|
# if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
# define littleendian 0
|
||||||
|
# elif BYTE_ORDER == LITTLE_ENDIAN
|
||||||
|
# define littleendian 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef littleendian
|
||||||
|
/* can't distinguish endian in compile time */
|
||||||
|
static inline int
|
||||||
|
check_little_endian(void)
|
||||||
|
{
|
||||||
|
unsigned int n = 1;
|
||||||
|
return (*(unsigned char *)&n == 1);
|
||||||
|
}
|
||||||
|
# define littleendian check_little_endian()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MRB_END_DECL
|
||||||
|
|
||||||
|
#endif /* MRUBY_ENDIAN_H */
|
||||||
+39
-5
@@ -23,7 +23,8 @@ struct RException {
|
|||||||
|
|
||||||
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
|
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
|
||||||
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
|
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
|
||||||
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
|
#define mrb_exc_new_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
|
||||||
|
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_lit(mrb, c, lit)
|
||||||
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
|
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
|
||||||
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
|
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
|
||||||
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);
|
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);
|
||||||
@@ -32,10 +33,10 @@ MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_va
|
|||||||
/* declaration for `fail` method */
|
/* declaration for `fail` method */
|
||||||
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
|
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
|
||||||
|
|
||||||
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
|
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT32) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
|
||||||
struct RBreak {
|
struct RBreak {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
struct RProc *proc;
|
const struct RProc *proc;
|
||||||
mrb_value val;
|
mrb_value val;
|
||||||
};
|
};
|
||||||
#define mrb_break_value_get(brk) ((brk)->val)
|
#define mrb_break_value_get(brk) ((brk)->val)
|
||||||
@@ -43,7 +44,7 @@ struct RBreak {
|
|||||||
#else
|
#else
|
||||||
struct RBreak {
|
struct RBreak {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
struct RProc *proc;
|
const struct RProc *proc;
|
||||||
union mrb_value_union value;
|
union mrb_value_union value;
|
||||||
};
|
};
|
||||||
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
|
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
|
||||||
@@ -62,10 +63,43 @@ mrb_break_value_set(struct RBreak *brk, mrb_value val)
|
|||||||
brk->flags &= ~RBREAK_VALUE_TT_MASK;
|
brk->flags &= ~RBREAK_VALUE_TT_MASK;
|
||||||
brk->flags |= val.tt;
|
brk->flags |= val.tt;
|
||||||
}
|
}
|
||||||
#endif /* MRB_64BIT || MRB_USE_FLOAT || MRB_NAN_BOXING || MRB_WORD_BOXING */
|
#endif /* MRB_64BIT || MRB_USE_FLOAT32 || MRB_NAN_BOXING || MRB_WORD_BOXING */
|
||||||
#define mrb_break_proc_get(brk) ((brk)->proc)
|
#define mrb_break_proc_get(brk) ((brk)->proc)
|
||||||
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
|
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
|
||||||
|
|
||||||
|
#define RBREAK_TAG_FOREACH(f) \
|
||||||
|
f(RBREAK_TAG_BREAK, 0) \
|
||||||
|
f(RBREAK_TAG_BREAK_UPPER, 1) \
|
||||||
|
f(RBREAK_TAG_BREAK_INTARGET, 2) \
|
||||||
|
f(RBREAK_TAG_RETURN_BLOCK, 3) \
|
||||||
|
f(RBREAK_TAG_RETURN, 4) \
|
||||||
|
f(RBREAK_TAG_RETURN_TOPLEVEL, 5) \
|
||||||
|
f(RBREAK_TAG_JUMP, 6) \
|
||||||
|
f(RBREAK_TAG_STOP, 7)
|
||||||
|
|
||||||
|
#define RBREAK_TAG_DEFINE(tag, i) tag = i,
|
||||||
|
enum {
|
||||||
|
RBREAK_TAG_FOREACH(RBREAK_TAG_DEFINE)
|
||||||
|
};
|
||||||
|
#undef RBREAK_TAG_DEFINE
|
||||||
|
|
||||||
|
#define RBREAK_TAG_BIT 3
|
||||||
|
#define RBREAK_TAG_BIT_OFF 8
|
||||||
|
#define RBREAK_TAG_MASK (~(~UINT32_C(0) << RBREAK_TAG_BIT))
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
mrb_break_tag_get(struct RBreak *brk)
|
||||||
|
{
|
||||||
|
return (brk->flags >> RBREAK_TAG_BIT_OFF) & RBREAK_TAG_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mrb_break_tag_set(struct RBreak *brk, uint32_t tag)
|
||||||
|
{
|
||||||
|
brk->flags &= ~(RBREAK_TAG_MASK << RBREAK_TAG_BIT_OFF);
|
||||||
|
brk->flags |= (tag & RBREAK_TAG_MASK) << RBREAK_TAG_BIT_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protect
|
* Protect
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct mrb_state;
|
|||||||
#define MRB_EACH_OBJ_BREAK 1
|
#define MRB_EACH_OBJ_BREAK 1
|
||||||
typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
|
typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
|
||||||
void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
|
void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
|
||||||
|
size_t mrb_objspace_page_slot_size(void);
|
||||||
MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
|
MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
|
||||||
|
|
||||||
#ifndef MRB_GC_ARENA_SIZE
|
#ifndef MRB_GC_ARENA_SIZE
|
||||||
|
|||||||
+32
-12
@@ -14,15 +14,28 @@
|
|||||||
*/
|
*/
|
||||||
MRB_BEGIN_DECL
|
MRB_BEGIN_DECL
|
||||||
|
|
||||||
|
/* offset of `iv` must be 3 words */
|
||||||
struct RHash {
|
struct RHash {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
|
#ifdef MRB_64BIT
|
||||||
|
uint32_t size;
|
||||||
struct iv_tbl *iv;
|
struct iv_tbl *iv;
|
||||||
struct htable *ht;
|
uint32_t ea_capa;
|
||||||
|
uint32_t ea_n_used;
|
||||||
|
#else
|
||||||
|
struct iv_tbl *iv;
|
||||||
|
uint32_t size;
|
||||||
|
#endif
|
||||||
|
union {
|
||||||
|
struct hash_entry *ea;
|
||||||
|
struct hash_table *ht;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
|
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
|
||||||
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
|
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
|
||||||
|
|
||||||
|
size_t mrb_hash_memsize(mrb_value obj);
|
||||||
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
|
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
|
||||||
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
|
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
|
||||||
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
|
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
|
||||||
@@ -178,8 +191,9 @@ MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
|
|||||||
MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
|
MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies the hash.
|
* Copies the hash. This function does NOT copy the instance variables
|
||||||
*
|
* (except for the default value). Use mrb_obj_dup() to copy the instance
|
||||||
|
* variables as well.
|
||||||
*
|
*
|
||||||
* @param mrb The mruby state reference.
|
* @param mrb The mruby state reference.
|
||||||
* @param hash The target hash.
|
* @param hash The target hash.
|
||||||
@@ -197,16 +211,22 @@ MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
|
|||||||
*/
|
*/
|
||||||
MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
|
MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
|
||||||
|
|
||||||
/* RHASH_TBL allocates st_table if not available. */
|
#define RHASH(hash) ((struct RHash*)(mrb_ptr(hash)))
|
||||||
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
|
|
||||||
#define RHASH_TBL(h) (RHASH(h)->ht)
|
|
||||||
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
|
|
||||||
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
|
|
||||||
|
|
||||||
#define MRB_HASH_DEFAULT 1
|
#define MRB_HASH_IB_BIT_BIT 5
|
||||||
#define MRB_HASH_PROC_DEFAULT 2
|
#define MRB_HASH_AR_EA_CAPA_BIT 5
|
||||||
#define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT)
|
#define MRB_HASH_IB_BIT_SHIFT 0
|
||||||
#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
|
#define MRB_HASH_AR_EA_CAPA_SHIFT 0
|
||||||
|
#define MRB_HASH_AR_EA_N_USED_SHIFT MRB_HASH_AR_EA_CAPA_BIT
|
||||||
|
#define MRB_HASH_SIZE_FLAGS_SHIFT (MRB_HASH_AR_EA_CAPA_BIT * 2)
|
||||||
|
#define MRB_HASH_IB_BIT_MASK ((1 << MRB_HASH_IB_BIT_BIT) - 1)
|
||||||
|
#define MRB_HASH_AR_EA_CAPA_MASK ((1 << MRB_HASH_AR_EA_CAPA_BIT) - 1)
|
||||||
|
#define MRB_HASH_AR_EA_N_USED_MASK (MRB_HASH_AR_EA_CAPA_MASK << MRB_HASH_AR_EA_N_USED_SHIFT)
|
||||||
|
#define MRB_HASH_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 0))
|
||||||
|
#define MRB_HASH_PROC_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 1))
|
||||||
|
#define MRB_HASH_HT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 2))
|
||||||
|
#define MRB_RHASH_DEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_DEFAULT)
|
||||||
|
#define MRB_RHASH_PROCDEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_PROC_DEFAULT)
|
||||||
|
|
||||||
/* GC functions */
|
/* GC functions */
|
||||||
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
|
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
|
||||||
|
|||||||
+63
-13
@@ -16,36 +16,72 @@
|
|||||||
MRB_BEGIN_DECL
|
MRB_BEGIN_DECL
|
||||||
|
|
||||||
enum irep_pool_type {
|
enum irep_pool_type {
|
||||||
IREP_TT_STRING,
|
IREP_TT_STR = 0, /* string (need free) */
|
||||||
IREP_TT_FIXNUM,
|
IREP_TT_SSTR = 2, /* string (static) */
|
||||||
IREP_TT_FLOAT,
|
IREP_TT_INT32 = 1, /* 32bit integer */
|
||||||
|
IREP_TT_INT64 = 3, /* 64bit integer */
|
||||||
|
IREP_TT_FLOAT = 5, /* float (double/float) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mrb_locals {
|
#define IREP_TT_NFLAG 1 /* number (non string) flag */
|
||||||
mrb_sym name;
|
#define IREP_TT_SFLAG 2 /* static string flag */
|
||||||
uint16_t r;
|
|
||||||
|
typedef struct mrb_pool_value {
|
||||||
|
uint32_t tt; /* packed type and length (for string) */
|
||||||
|
union {
|
||||||
|
const char *str;
|
||||||
|
int32_t i32;
|
||||||
|
#if defined(MRB_64BIT) || defined(MRB_INT64)
|
||||||
|
int64_t i64;
|
||||||
|
#endif
|
||||||
|
#ifndef MRB_NO_FLOAT
|
||||||
|
mrb_float f;
|
||||||
|
#endif
|
||||||
|
} u;
|
||||||
|
} mrb_pool_value;
|
||||||
|
|
||||||
|
enum mrb_catch_type {
|
||||||
|
MRB_CATCH_RESCUE = 0,
|
||||||
|
MRB_CATCH_ENSURE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mrb_irep_catch_handler {
|
||||||
|
uint8_t type; /* enum mrb_catch_type */
|
||||||
|
uint8_t begin[4]; /* The starting address to match the hander. Includes this. */
|
||||||
|
uint8_t end[4]; /* The endpoint address that matches the hander. Not Includes this. */
|
||||||
|
uint8_t target[4]; /* The address to jump to if a match is made. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Program data array struct */
|
/* Program data array struct */
|
||||||
typedef struct mrb_irep {
|
typedef struct mrb_irep {
|
||||||
uint16_t nlocals; /* Number of local variables */
|
uint16_t nlocals; /* Number of local variables */
|
||||||
uint16_t nregs; /* Number of register variables */
|
uint16_t nregs; /* Number of register variables */
|
||||||
|
uint16_t clen; /* Number of catch handlers */
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
|
|
||||||
const mrb_code *iseq;
|
const mrb_code *iseq;
|
||||||
mrb_value *pool;
|
/*
|
||||||
mrb_sym *syms;
|
* A catch handler table is placed after the iseq entity.
|
||||||
struct mrb_irep **reps;
|
* The reason it doesn't add fields to the structure is to keep the mrb_irep structure from bloating.
|
||||||
|
* The catch handler table can be obtained with `mrb_irep_catch_handler_table(irep)`.
|
||||||
|
*/
|
||||||
|
const mrb_pool_value *pool;
|
||||||
|
const mrb_sym *syms;
|
||||||
|
const struct mrb_irep * const *reps;
|
||||||
|
|
||||||
struct mrb_locals *lv;
|
const mrb_sym *lv;
|
||||||
/* debug info */
|
/* debug info */
|
||||||
struct mrb_irep_debug_info* debug_info;
|
struct mrb_irep_debug_info* debug_info;
|
||||||
|
|
||||||
uint16_t ilen, plen, slen, rlen;
|
uint32_t ilen;
|
||||||
uint32_t refcnt;
|
uint16_t plen, slen;
|
||||||
|
uint16_t rlen;
|
||||||
|
uint16_t refcnt;
|
||||||
} mrb_irep;
|
} mrb_irep;
|
||||||
|
|
||||||
#define MRB_ISEQ_NO_FREE 1
|
#define MRB_ISEQ_NO_FREE 1
|
||||||
|
#define MRB_IREP_NO_FREE 2
|
||||||
|
#define MRB_IREP_STATIC (MRB_ISEQ_NO_FREE | MRB_IREP_NO_FREE)
|
||||||
|
|
||||||
MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
|
MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
|
||||||
|
|
||||||
@@ -87,11 +123,25 @@ struct mrb_insn_data {
|
|||||||
uint8_t insn;
|
uint8_t insn;
|
||||||
uint16_t a;
|
uint16_t a;
|
||||||
uint16_t b;
|
uint16_t b;
|
||||||
uint8_t c;
|
uint16_t c;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
|
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
|
||||||
|
|
||||||
|
static inline const struct mrb_irep_catch_handler *
|
||||||
|
mrb_irep_catch_handler_table(const struct mrb_irep *irep)
|
||||||
|
{
|
||||||
|
if (irep->clen > 0) {
|
||||||
|
return (const struct mrb_irep_catch_handler*)(irep->iseq + irep->ilen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (const struct mrb_irep_catch_handler*)NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define mrb_irep_catch_handler_pack(n, v) uint32_to_bin(n, v)
|
||||||
|
#define mrb_irep_catch_handler_unpack(v) bin_to_uint32(v)
|
||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|
||||||
#endif /* MRUBY_IREP_H */
|
#endif /* MRUBY_IREP_H */
|
||||||
|
|||||||
+6
-14
@@ -61,7 +61,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
|
|||||||
typedef struct kh_##name { \
|
typedef struct kh_##name { \
|
||||||
khint_t n_buckets; \
|
khint_t n_buckets; \
|
||||||
khint_t size; \
|
khint_t size; \
|
||||||
khint_t n_occupied; \
|
|
||||||
uint8_t *ed_flags; \
|
uint8_t *ed_flags; \
|
||||||
khkey_t *keys; \
|
khkey_t *keys; \
|
||||||
khval_t *vals; \
|
khval_t *vals; \
|
||||||
@@ -73,7 +72,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
|
|||||||
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h); \
|
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h); \
|
||||||
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
|
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
|
||||||
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret); \
|
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret); \
|
||||||
void kh_put_prepare_##name(mrb_state *mrb, kh_##name##_t *h); \
|
|
||||||
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets); \
|
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets); \
|
||||||
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x); \
|
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x); \
|
||||||
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
|
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
|
||||||
@@ -93,7 +91,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
khval_t: value data type
|
khval_t: value data type
|
||||||
kh_is_map: (0: hash set / 1: hash map)
|
kh_is_map: (0: hash set / 1: hash map)
|
||||||
__hash_func: hash function
|
__hash_func: hash function
|
||||||
__hash_equal: hash comparation function
|
__hash_equal: hash comparison function
|
||||||
*/
|
*/
|
||||||
#define KHASH_DEFINE(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
|
#define KHASH_DEFINE(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
|
||||||
mrb_noreturn void mrb_raise_nomemory(mrb_state *mrb); \
|
mrb_noreturn void mrb_raise_nomemory(mrb_state *mrb); \
|
||||||
@@ -103,7 +101,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
size_t len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
|
size_t len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
|
||||||
uint8_t *p = (uint8_t*)mrb_malloc_simple(mrb, sizeof(uint8_t)*sz/4+len*sz); \
|
uint8_t *p = (uint8_t*)mrb_malloc_simple(mrb, sizeof(uint8_t)*sz/4+len*sz); \
|
||||||
if (!p) { return 1; } \
|
if (!p) { return 1; } \
|
||||||
h->size = h->n_occupied = 0; \
|
h->size = 0; \
|
||||||
h->keys = (khkey_t *)p; \
|
h->keys = (khkey_t *)p; \
|
||||||
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
|
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
|
||||||
h->ed_flags = p+len*sz; \
|
h->ed_flags = p+len*sz; \
|
||||||
@@ -143,7 +141,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
(void)mrb; \
|
(void)mrb; \
|
||||||
if (h && h->ed_flags) { \
|
if (h && h->ed_flags) { \
|
||||||
kh_fill_flags(h->ed_flags, 0xaa, h->n_buckets/4); \
|
kh_fill_flags(h->ed_flags, 0xaa, h->n_buckets/4); \
|
||||||
h->size = h->n_occupied = 0; \
|
h->size = 0; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
|
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
|
||||||
@@ -184,16 +182,12 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
mrb_free(mrb, old_keys); \
|
mrb_free(mrb, old_keys); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
void kh_put_prepare_##name(mrb_state *mrb, kh_##name##_t *h) \
|
|
||||||
{ \
|
|
||||||
if (h->n_occupied >= khash_upper_bound(h)) { \
|
|
||||||
kh_resize_##name(mrb, h, h->n_buckets*2); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret) \
|
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret) \
|
||||||
{ \
|
{ \
|
||||||
khint_t k, del_k, step = 0; \
|
khint_t k, del_k, step = 0; \
|
||||||
kh_put_prepare_##name(mrb, h); \
|
if (h->size >= khash_upper_bound(h)) { \
|
||||||
|
kh_resize_##name(mrb, h, h->n_buckets*2); \
|
||||||
|
} \
|
||||||
k = __hash_func(mrb,key) & khash_mask(h); \
|
k = __hash_func(mrb,key) & khash_mask(h); \
|
||||||
del_k = kh_end(h); \
|
del_k = kh_end(h); \
|
||||||
while (!__ac_isempty(h->ed_flags, k)) { \
|
while (!__ac_isempty(h->ed_flags, k)) { \
|
||||||
@@ -221,7 +215,6 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
h->keys[k] = key; \
|
h->keys[k] = key; \
|
||||||
h->ed_flags[k/4] &= ~__m_empty[k%4]; \
|
h->ed_flags[k/4] &= ~__m_empty[k%4]; \
|
||||||
h->size++; \
|
h->size++; \
|
||||||
h->n_occupied++; \
|
|
||||||
if (ret) *ret = 1; \
|
if (ret) *ret = 1; \
|
||||||
return k; \
|
return k; \
|
||||||
} \
|
} \
|
||||||
@@ -256,7 +249,6 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
|||||||
#define kh_destroy(name, mrb, h) kh_destroy_##name(mrb, h)
|
#define kh_destroy(name, mrb, h) kh_destroy_##name(mrb, h)
|
||||||
#define kh_clear(name, mrb, h) kh_clear_##name(mrb, h)
|
#define kh_clear(name, mrb, h) kh_clear_##name(mrb, h)
|
||||||
#define kh_resize(name, mrb, h, s) kh_resize_##name(mrb, h, s)
|
#define kh_resize(name, mrb, h, s) kh_resize_##name(mrb, h, s)
|
||||||
#define kh_put_prepare(name, mrb, h) kh_put_prepare_##name(mrb, h)
|
|
||||||
#define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k, NULL)
|
#define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k, NULL)
|
||||||
#define kh_put2(name, mrb, h, k, r) kh_put_##name(mrb, h, k, r)
|
#define kh_put2(name, mrb, h, k, r) kh_put_##name(mrb, h, k, r)
|
||||||
#define kh_get(name, mrb, h, k) kh_get_##name(mrb, h, k)
|
#define kh_get(name, mrb, h, k) kh_get_##name(mrb, h, k)
|
||||||
|
|||||||
+36
-63
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
** @file mruby/numeric.h - Numeric, Integer, Float, Fixnum class
|
** @file mruby/numeric.h - Numeric, Integer, Float class
|
||||||
**
|
**
|
||||||
** See Copyright Notice in mruby.h
|
** See Copyright Notice in mruby.h
|
||||||
*/
|
*/
|
||||||
@@ -12,17 +12,17 @@
|
|||||||
/**
|
/**
|
||||||
* Numeric class and it's sub-classes.
|
* Numeric class and it's sub-classes.
|
||||||
*
|
*
|
||||||
* Integer, Float and Fixnum
|
* Integer and Float
|
||||||
*/
|
*/
|
||||||
MRB_BEGIN_DECL
|
MRB_BEGIN_DECL
|
||||||
|
|
||||||
#define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_INT_MAX)
|
#define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_FIXNUM_MAX)
|
||||||
#define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_INT_MIN)
|
#define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_FIXNUM_MIN)
|
||||||
#define TYPED_FIXABLE(f,t) (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
|
#define TYPED_FIXABLE(f,t) (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
|
||||||
#define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
|
#define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
|
||||||
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
|
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
|
||||||
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
|
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#ifdef MRB_INT64
|
#ifdef MRB_INT64
|
||||||
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
|
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
|
||||||
#else
|
#else
|
||||||
@@ -30,16 +30,15 @@ MRB_BEGIN_DECL
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
|
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
|
||||||
#endif
|
#endif
|
||||||
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
|
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
|
||||||
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
|
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
|
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
|
||||||
MRB_API int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f);
|
MRB_API int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f);
|
||||||
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
|
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
|
||||||
MRB_API mrb_value mrb_int_value(mrb_state *mrb, mrb_float f);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MRB_API mrb_value mrb_num_plus(mrb_state *mrb, mrb_value x, mrb_value y);
|
MRB_API mrb_value mrb_num_plus(mrb_state *mrb, mrb_value x, mrb_value y);
|
||||||
@@ -71,103 +70,77 @@ MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
|
|||||||
|
|
||||||
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
||||||
|
|
||||||
#ifndef MRB_WORD_BOXING
|
|
||||||
# define WBCHK(x) 0
|
|
||||||
#else
|
|
||||||
# define WBCHK(x) !FIXABLE(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
||||||
{
|
{
|
||||||
return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum);
|
return __builtin_add_overflow(augend, addend, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
||||||
{
|
{
|
||||||
return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference);
|
return __builtin_sub_overflow(minuend, subtrahend, difference);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
||||||
{
|
{
|
||||||
return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product);
|
return __builtin_mul_overflow(multiplier, multiplicand, product);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef WBCHK
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define MRB_UINT_MAKE2(n) uint ## n ## _t
|
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1))
|
||||||
#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
|
|
||||||
#define mrb_uint MRB_UINT_MAKE(MRB_INT_BIT)
|
|
||||||
|
|
||||||
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT))
|
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
mrb_int_add_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||||
{
|
{
|
||||||
mrb_uint x = (mrb_uint)augend;
|
mrb_uint x = (mrb_uint)a;
|
||||||
mrb_uint y = (mrb_uint)addend;
|
mrb_uint y = (mrb_uint)b;
|
||||||
mrb_uint z = (mrb_uint)(x + y);
|
mrb_uint z = (mrb_uint)(x + y);
|
||||||
*sum = (mrb_int)z;
|
*c = (mrb_int)z;
|
||||||
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
mrb_int_sub_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||||
{
|
{
|
||||||
mrb_uint x = (mrb_uint)minuend;
|
mrb_uint x = (mrb_uint)a;
|
||||||
mrb_uint y = (mrb_uint)subtrahend;
|
mrb_uint y = (mrb_uint)b;
|
||||||
mrb_uint z = (mrb_uint)(x - y);
|
mrb_uint z = (mrb_uint)(x - y);
|
||||||
*difference = (mrb_int)z;
|
*c = (mrb_int)z;
|
||||||
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mrb_bool
|
static inline mrb_bool
|
||||||
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||||
{
|
{
|
||||||
#if MRB_INT_BIT == 32
|
#ifdef MRB_INT32
|
||||||
int64_t n = (int64_t)multiplier * multiplicand;
|
int64_t n = (int64_t)a * b;
|
||||||
*product = (mrb_int)n;
|
*c = (mrb_int)n;
|
||||||
return !FIXABLE(n);
|
return n > MRB_INT_MAX || n < MRB_INT_MIN;
|
||||||
#else
|
#else /* MRB_INT64 */
|
||||||
if (multiplier > 0) {
|
if (a > 0 && b > 0 && a > MRB_INT_MAX / b) return TRUE;
|
||||||
if (multiplicand > 0) {
|
if (a < 0 && b > 0 && a < MRB_INT_MIN / b) return TRUE;
|
||||||
if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
|
if (a > 0 && b < 0 && b < MRB_INT_MIN / a) return TRUE;
|
||||||
}
|
if (a < 0 && b < 0 && (a <= MRB_INT_MIN || b <= MRB_INT_MIN || -a > MRB_INT_MAX / -b))
|
||||||
else {
|
return TRUE;
|
||||||
if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
*c = a * b;
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (multiplicand > 0) {
|
|
||||||
if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*product = multiplier * multiplicand;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MRB_INT_OVERFLOW_MASK
|
#undef MRB_INT_OVERFLOW_MASK
|
||||||
#undef mrb_uint
|
|
||||||
#undef MRB_UINT_MAKE
|
|
||||||
#undef MRB_UINT_MAKE2
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <float.h>
|
# include <float.h>
|
||||||
|
|
||||||
# define MRB_FLT_RADIX FLT_RADIX
|
# define MRB_FLT_RADIX FLT_RADIX
|
||||||
|
|
||||||
# ifdef MRB_USE_FLOAT
|
# ifdef MRB_USE_FLOAT32
|
||||||
# define MRB_FLT_MANT_DIG FLT_MANT_DIG
|
# define MRB_FLT_MANT_DIG FLT_MANT_DIG
|
||||||
# define MRB_FLT_EPSILON FLT_EPSILON
|
# define MRB_FLT_EPSILON FLT_EPSILON
|
||||||
# define MRB_FLT_DIG FLT_DIG
|
# define MRB_FLT_DIG FLT_DIG
|
||||||
@@ -178,7 +151,7 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
|||||||
# define MRB_FLT_MAX FLT_MAX
|
# define MRB_FLT_MAX FLT_MAX
|
||||||
# define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
|
# define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
|
||||||
|
|
||||||
# else /* not MRB_USE_FLOAT */
|
# else /* not MRB_USE_FLOAT32 */
|
||||||
# define MRB_FLT_MANT_DIG DBL_MANT_DIG
|
# define MRB_FLT_MANT_DIG DBL_MANT_DIG
|
||||||
# define MRB_FLT_EPSILON DBL_EPSILON
|
# define MRB_FLT_EPSILON DBL_EPSILON
|
||||||
# define MRB_FLT_DIG DBL_DIG
|
# define MRB_FLT_DIG DBL_DIG
|
||||||
@@ -188,8 +161,8 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
|||||||
# define MRB_FLT_MAX_EXP DBL_MAX_EXP
|
# define MRB_FLT_MAX_EXP DBL_MAX_EXP
|
||||||
# define MRB_FLT_MAX DBL_MAX
|
# define MRB_FLT_MAX DBL_MAX
|
||||||
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
|
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
|
||||||
# endif /* MRB_USE_FLOAT */
|
# endif /* MRB_USE_FLOAT32 */
|
||||||
#endif /* MRB_WITHOUT_FLOAT */
|
#endif /* MRB_NO_FLOAT */
|
||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|
||||||
|
|||||||
+1
-27
@@ -36,34 +36,8 @@ enum mrb_insn {
|
|||||||
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
||||||
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
|
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
|
||||||
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
||||||
|
#define FETCH_BSS() do {a=READ_B(); b=READ_S(); c=READ_S();} while (0)
|
||||||
#define FETCH_S() do {a=READ_S();} while (0)
|
#define FETCH_S() do {a=READ_S();} while (0)
|
||||||
#define FETCH_W() do {a=READ_W();} while (0)
|
#define FETCH_W() do {a=READ_W();} while (0)
|
||||||
|
|
||||||
/* with OP_EXT1 (1st 16bit) */
|
|
||||||
#define FETCH_Z_1() FETCH_Z()
|
|
||||||
#define FETCH_B_1() FETCH_S()
|
|
||||||
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
|
|
||||||
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); c=READ_B();} while (0)
|
|
||||||
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
|
|
||||||
#define FETCH_S_1() FETCH_S()
|
|
||||||
#define FETCH_W_1() FETCH_W()
|
|
||||||
|
|
||||||
/* with OP_EXT2 (2nd 16bit) */
|
|
||||||
#define FETCH_Z_2() FETCH_Z()
|
|
||||||
#define FETCH_B_2() FETCH_B()
|
|
||||||
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
|
|
||||||
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); c=READ_B();} while (0)
|
|
||||||
#define FETCH_BS_2() FETCH_BS()
|
|
||||||
#define FETCH_S_2() FETCH_S()
|
|
||||||
#define FETCH_W_2() FETCH_W()
|
|
||||||
|
|
||||||
/* with OP_EXT3 (1st & 2nd 16bit) */
|
|
||||||
#define FETCH_Z_3() FETCH_Z()
|
|
||||||
#define FETCH_B_3() FETCH_B()
|
|
||||||
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
||||||
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); c=READ_B();} while (0)
|
|
||||||
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
|
|
||||||
#define FETCH_S_3() FETCH_S()
|
|
||||||
#define FETCH_W_3() FETCH_W()
|
|
||||||
|
|
||||||
#endif /* MRUBY_OPCODE_H */
|
#endif /* MRUBY_OPCODE_H */
|
||||||
|
|||||||
+27
-23
@@ -1,11 +1,12 @@
|
|||||||
/* operand types:
|
/* operand types:
|
||||||
+ Z: no operand (Z,Z,Z,Z)
|
+ Z: no operand
|
||||||
+ B: 8bit (B,S,B,B)
|
+ B: 8bit
|
||||||
+ BB: 8+8bit (BB,SB,BS,SS)
|
+ BB: 8+8bit
|
||||||
+ BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
|
+ BBB: 8+8+8bit
|
||||||
+ BS: 8+16bit (BS,SS,BS,BS)
|
+ BS: 8+16bit
|
||||||
+ S: 16bit (S,S,S,S)
|
+ BSS: 8+16+16bit
|
||||||
+ W: 24bit (W,W,W,W)
|
+ S: 16bit
|
||||||
|
+ W: 24bit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
@@ -14,6 +15,7 @@ operation code operands semantics
|
|||||||
OPCODE(NOP, Z) /* no operation */
|
OPCODE(NOP, Z) /* no operation */
|
||||||
OPCODE(MOVE, BB) /* R(a) = R(b) */
|
OPCODE(MOVE, BB) /* R(a) = R(b) */
|
||||||
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
|
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
|
||||||
|
OPCODE(LOADL16, BS) /* R(a) = Pool(b) */
|
||||||
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
|
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
|
||||||
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
|
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
|
||||||
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
|
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
|
||||||
@@ -25,7 +27,10 @@ OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
|
|||||||
OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
|
OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
|
||||||
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
|
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
|
||||||
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
|
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
|
||||||
|
OPCODE(LOADI16, BS) /* R(a) = mrb_int(b) */
|
||||||
|
OPCODE(LOADI32, BSS) /* R(a) = mrb_int((b<<16)+c) */
|
||||||
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
|
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
|
||||||
|
OPCODE(LOADSYM16, BS) /* R(a) = Syms(b) */
|
||||||
OPCODE(LOADNIL, B) /* R(a) = nil */
|
OPCODE(LOADNIL, B) /* R(a) = nil */
|
||||||
OPCODE(LOADSELF, B) /* R(a) = self */
|
OPCODE(LOADSELF, B) /* R(a) = self */
|
||||||
OPCODE(LOADT, B) /* R(a) = true */
|
OPCODE(LOADT, B) /* R(a) = true */
|
||||||
@@ -44,28 +49,26 @@ OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
|
|||||||
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
|
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
|
||||||
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
|
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
|
||||||
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
|
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
|
||||||
OPCODE(JMP, S) /* pc=a */
|
OPCODE(JMP, S) /* pc+=a */
|
||||||
OPCODE(JMPIF, BS) /* if R(a) pc=b */
|
OPCODE(JMPIF, BS) /* if R(a) pc+=b */
|
||||||
OPCODE(JMPNOT, BS) /* if !R(a) pc=b */
|
OPCODE(JMPNOT, BS) /* if !R(a) pc+=b */
|
||||||
OPCODE(JMPNIL, BS) /* if R(a)==nil pc=b */
|
OPCODE(JMPNIL, BS) /* if R(a)==nil pc+=b */
|
||||||
OPCODE(ONERR, S) /* rescue_push(a) */
|
OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
|
||||||
OPCODE(EXCEPT, B) /* R(a) = exc */
|
OPCODE(EXCEPT, B) /* R(a) = exc */
|
||||||
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
||||||
OPCODE(POPERR, B) /* a.times{rescue_pop()} */
|
OPCODE(RAISEIF, B) /* raise(R(a)) if R(a) */
|
||||||
OPCODE(RAISE, B) /* raise(R(a)) */
|
|
||||||
OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
|
|
||||||
OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
|
|
||||||
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
||||||
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
||||||
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
||||||
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) */
|
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) */
|
||||||
|
OPCODE(SENDVK, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),**(a+2),&R(a+3)) # todo */
|
||||||
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
|
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
|
||||||
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
|
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
|
||||||
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
|
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
|
||||||
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
||||||
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
|
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) */
|
||||||
OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
|
OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
|
||||||
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
|
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) */
|
||||||
OPCODE(RETURN, B) /* return R(a) (normal) */
|
OPCODE(RETURN, B) /* return R(a) (normal) */
|
||||||
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
|
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
|
||||||
OPCODE(BREAK, B) /* break R(a) */
|
OPCODE(BREAK, B) /* break R(a) */
|
||||||
@@ -91,19 +94,24 @@ OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
|
|||||||
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
|
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
|
||||||
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
|
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
|
||||||
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
|
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
|
||||||
|
OPCODE(STRING16, BS) /* R(a) = str_dup(Lit(b)) */
|
||||||
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
|
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
|
||||||
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1)) */
|
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1)) */
|
||||||
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b*2)) */
|
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b*2)) */
|
||||||
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
|
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
|
||||||
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
||||||
|
OPCODE(LAMBDA16, BS) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
||||||
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
||||||
|
OPCODE(BLOCK16, BS) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
||||||
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
||||||
|
OPCODE(METHOD16, BS) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
||||||
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
|
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
|
||||||
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
|
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
|
||||||
OPCODE(OCLASS, B) /* R(a) = ::Object */
|
OPCODE(OCLASS, B) /* R(a) = ::Object */
|
||||||
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
||||||
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
||||||
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
||||||
|
OPCODE(EXEC16, BS) /* R(a) = blockexec(R(a),SEQ[b]) */
|
||||||
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
||||||
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
||||||
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
||||||
@@ -111,8 +119,4 @@ OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
|
|||||||
OPCODE(TCLASS, B) /* R(a) = target_class */
|
OPCODE(TCLASS, B) /* R(a) = target_class */
|
||||||
OPCODE(DEBUG, BBB) /* print a,b,c */
|
OPCODE(DEBUG, BBB) /* print a,b,c */
|
||||||
OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
|
OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
|
||||||
OPCODE(EXT1, Z) /* make 1st operand 16bit */
|
|
||||||
OPCODE(EXT2, Z) /* make 2nd operand 16bit */
|
|
||||||
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
|
|
||||||
OPCODE(STOP, Z) /* stop VM */
|
OPCODE(STOP, Z) /* stop VM */
|
||||||
OPCODE(LOADI16, BS) /* R(a) = mrb_int(b) */
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
** @file mruby/presym.h - Preallocated Symbols
|
||||||
|
**
|
||||||
|
** See Copyright Notice in mruby.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRUBY_PRESYM_H
|
||||||
|
#define MRUBY_PRESYM_H
|
||||||
|
|
||||||
|
#if defined(MRB_NO_PRESYM)
|
||||||
|
# include <mruby/presym/disable.h>
|
||||||
|
#elif !defined(MRB_PRESYM_SCANNING)
|
||||||
|
# include <mruby/presym/enable.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Where `mrb_intern_lit` is allowed for symbol interning, it is directly
|
||||||
|
* replaced by the symbol ID if presym is enabled by using the following
|
||||||
|
* macros.
|
||||||
|
*
|
||||||
|
* MRB_OPSYM(xor) //=> ^ (Operator)
|
||||||
|
* MRB_CVSYM(xor) //=> @@xor (Class Variable)
|
||||||
|
* MRB_IVSYM(xor) //=> @xor (Instance Variable)
|
||||||
|
* MRB_SYM_B(xor) //=> xor! (Method with Bang)
|
||||||
|
* MRB_SYM_Q(xor) //=> xor? (Method with Question mark)
|
||||||
|
* MRB_SYM_E(xor) //=> xor= (Method with Equal)
|
||||||
|
* MRB_SYM(xor) //=> xor (Word characters)
|
||||||
|
*
|
||||||
|
* For `MRB_OPSYM`, specify the names corresponding to operators (see
|
||||||
|
* `MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that
|
||||||
|
* can be specified for it). Other than that, describe only word characters
|
||||||
|
* excluding leading and ending punctuations.
|
||||||
|
*
|
||||||
|
* These macros are expanded to `mrb_intern_lit` if presym is disabled,
|
||||||
|
* therefore the mruby state variable is required. The above macros can be
|
||||||
|
* used when the variable name is `mrb`. If you want to use other variable
|
||||||
|
* names, you need to use macros with `_2` suffix, such as `MRB_SYM_2`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* MRUBY_PRESYM_H */
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
** @file mruby/presym/disable.h - Disable Preallocated Symbols
|
||||||
|
**
|
||||||
|
** See Copyright Notice in mruby.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRUBY_PRESYM_DISABLE_H
|
||||||
|
#define MRUBY_PRESYM_DISABLE_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define MRB_PRESYM_MAX 0
|
||||||
|
|
||||||
|
#define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
|
||||||
|
#define MRB_CVSYM(name) mrb_intern_lit(mrb, "@@" #name)
|
||||||
|
#define MRB_IVSYM(name) mrb_intern_lit(mrb, "@" #name)
|
||||||
|
#define MRB_SYM_B(name) mrb_intern_lit(mrb, #name "!")
|
||||||
|
#define MRB_SYM_Q(name) mrb_intern_lit(mrb, #name "?")
|
||||||
|
#define MRB_SYM_E(name) mrb_intern_lit(mrb, #name "=")
|
||||||
|
#define MRB_SYM(name) mrb_intern_lit(mrb, #name)
|
||||||
|
|
||||||
|
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name(mrb)
|
||||||
|
#define MRB_CVSYM_2(mrb, name) mrb_intern_lit(mrb, "@@" #name)
|
||||||
|
#define MRB_IVSYM_2(mrb, name) mrb_intern_lit(mrb, "@" #name)
|
||||||
|
#define MRB_SYM_B_2(mrb, name) mrb_intern_lit(mrb, #name "!")
|
||||||
|
#define MRB_SYM_Q_2(mrb, name) mrb_intern_lit(mrb, #name "?")
|
||||||
|
#define MRB_SYM_E_2(mrb, name) mrb_intern_lit(mrb, #name "=")
|
||||||
|
#define MRB_SYM_2(mrb, name) mrb_intern_lit(mrb, #name)
|
||||||
|
|
||||||
|
#define MRB_OPSYM__not(mrb) mrb_intern_lit(mrb, "!")
|
||||||
|
#define MRB_OPSYM__mod(mrb) mrb_intern_lit(mrb, "%")
|
||||||
|
#define MRB_OPSYM__and(mrb) mrb_intern_lit(mrb, "&")
|
||||||
|
#define MRB_OPSYM__mul(mrb) mrb_intern_lit(mrb, "*")
|
||||||
|
#define MRB_OPSYM__add(mrb) mrb_intern_lit(mrb, "+")
|
||||||
|
#define MRB_OPSYM__sub(mrb) mrb_intern_lit(mrb, "-")
|
||||||
|
#define MRB_OPSYM__div(mrb) mrb_intern_lit(mrb, "/")
|
||||||
|
#define MRB_OPSYM__lt(mrb) mrb_intern_lit(mrb, "<")
|
||||||
|
#define MRB_OPSYM__gt(mrb) mrb_intern_lit(mrb, ">")
|
||||||
|
#define MRB_OPSYM__xor(mrb) mrb_intern_lit(mrb, "^")
|
||||||
|
#define MRB_OPSYM__tick(mrb) mrb_intern_lit(mrb, "`")
|
||||||
|
#define MRB_OPSYM__or(mrb) mrb_intern_lit(mrb, "|")
|
||||||
|
#define MRB_OPSYM__neg(mrb) mrb_intern_lit(mrb, "~")
|
||||||
|
#define MRB_OPSYM__neq(mrb) mrb_intern_lit(mrb, "!=")
|
||||||
|
#define MRB_OPSYM__nmatch(mrb) mrb_intern_lit(mrb, "!~")
|
||||||
|
#define MRB_OPSYM__andand(mrb) mrb_intern_lit(mrb, "&&")
|
||||||
|
#define MRB_OPSYM__pow(mrb) mrb_intern_lit(mrb, "**")
|
||||||
|
#define MRB_OPSYM__plus(mrb) mrb_intern_lit(mrb, "+@")
|
||||||
|
#define MRB_OPSYM__minus(mrb) mrb_intern_lit(mrb, "-@")
|
||||||
|
#define MRB_OPSYM__lshift(mrb) mrb_intern_lit(mrb, "<<")
|
||||||
|
#define MRB_OPSYM__le(mrb) mrb_intern_lit(mrb, "<=")
|
||||||
|
#define MRB_OPSYM__eq(mrb) mrb_intern_lit(mrb, "==")
|
||||||
|
#define MRB_OPSYM__match(mrb) mrb_intern_lit(mrb, "=~")
|
||||||
|
#define MRB_OPSYM__ge(mrb) mrb_intern_lit(mrb, ">=")
|
||||||
|
#define MRB_OPSYM__rshift(mrb) mrb_intern_lit(mrb, ">>")
|
||||||
|
#define MRB_OPSYM__aref(mrb) mrb_intern_lit(mrb, "[]")
|
||||||
|
#define MRB_OPSYM__oror(mrb) mrb_intern_lit(mrb, "||")
|
||||||
|
#define MRB_OPSYM__cmp(mrb) mrb_intern_lit(mrb, "<=>")
|
||||||
|
#define MRB_OPSYM__eqq(mrb) mrb_intern_lit(mrb, "===")
|
||||||
|
#define MRB_OPSYM__aset(mrb) mrb_intern_lit(mrb, "[]=")
|
||||||
|
|
||||||
|
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
||||||
|
static mrb_sym name[size]; \
|
||||||
|
static void presym_init_##name(mrb_state *mrb) { \
|
||||||
|
mrb_sym name__[] = {__VA_ARGS__}; \
|
||||||
|
memcpy(name, name__, sizeof(name)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) presym_init_##name(mrb)
|
||||||
|
|
||||||
|
#endif /* MRUBY_PRESYM_DISABLE_H */
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
** @file mruby/presym/enable.h - Enable Preallocated Symbols
|
||||||
|
**
|
||||||
|
** See Copyright Notice in mruby.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRUBY_PRESYM_ENABLE_H
|
||||||
|
#define MRUBY_PRESYM_ENABLE_H
|
||||||
|
|
||||||
|
#include <mruby/presym/id.h>
|
||||||
|
|
||||||
|
#define MRB_OPSYM(name) MRB_OPSYM__##name
|
||||||
|
#define MRB_CVSYM(name) MRB_CVSYM__##name
|
||||||
|
#define MRB_IVSYM(name) MRB_IVSYM__##name
|
||||||
|
#define MRB_SYM_B(name) MRB_SYM_B__##name
|
||||||
|
#define MRB_SYM_Q(name) MRB_SYM_Q__##name
|
||||||
|
#define MRB_SYM_E(name) MRB_SYM_E__##name
|
||||||
|
#define MRB_SYM(name) MRB_SYM__##name
|
||||||
|
|
||||||
|
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name
|
||||||
|
#define MRB_CVSYM_2(mrb, name) MRB_CVSYM__##name
|
||||||
|
#define MRB_IVSYM_2(mrb, name) MRB_IVSYM__##name
|
||||||
|
#define MRB_SYM_B_2(mrb, name) MRB_SYM_B__##name
|
||||||
|
#define MRB_SYM_Q_2(mrb, name) MRB_SYM_Q__##name
|
||||||
|
#define MRB_SYM_E_2(mrb, name) MRB_SYM_E__##name
|
||||||
|
#define MRB_SYM_2(mrb, name) MRB_SYM__##name
|
||||||
|
|
||||||
|
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
||||||
|
static const mrb_sym name[] = {__VA_ARGS__};
|
||||||
|
|
||||||
|
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) (void)(mrb)
|
||||||
|
|
||||||
|
/* use MRB_SYM() for E_RUNTIME_ERROR etc. */
|
||||||
|
#undef MRB_ERROR_SYM
|
||||||
|
#define MRB_ERROR_SYM(sym) MRB_SYM(sym)
|
||||||
|
|
||||||
|
#endif /* MRUBY_PRESYM_ENABLE_H */
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
** @file mruby/presym/scanning.h - Scanning Preallocated Symbols
|
||||||
|
**
|
||||||
|
** See Copyright Notice in mruby.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRUBY_PRESYM_SCANNING_H
|
||||||
|
#define MRUBY_PRESYM_SCANNING_H
|
||||||
|
|
||||||
|
#define MRB_PRESYM_SCANNING_TAGGED(arg) <@! arg !@>
|
||||||
|
|
||||||
|
#undef mrb_intern_lit
|
||||||
|
#define mrb_intern_lit(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_intern_cstr(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_class_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_singleton_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_class(mrb, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_class_under(mrb, o, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_module(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_module_under(mrb, o, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_module_function(mrb, c, name, f, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_const(mrb, c, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
#define mrb_define_global_const(mrb, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||||
|
|
||||||
|
#define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
|
||||||
|
#define MRB_CVSYM(name) MRB_PRESYM_SCANNING_TAGGED("@@" #name)
|
||||||
|
#define MRB_IVSYM(name) MRB_PRESYM_SCANNING_TAGGED("@" #name)
|
||||||
|
#define MRB_SYM_B(name) MRB_PRESYM_SCANNING_TAGGED(#name "!")
|
||||||
|
#define MRB_SYM_Q(name) MRB_PRESYM_SCANNING_TAGGED(#name "?")
|
||||||
|
#define MRB_SYM_E(name) MRB_PRESYM_SCANNING_TAGGED(#name "=")
|
||||||
|
#define MRB_SYM(name) MRB_PRESYM_SCANNING_TAGGED(#name)
|
||||||
|
|
||||||
|
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name(mrb)
|
||||||
|
#define MRB_CVSYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED("@@" #name)
|
||||||
|
#define MRB_IVSYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED("@" #name)
|
||||||
|
#define MRB_SYM_B_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "!")
|
||||||
|
#define MRB_SYM_Q_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "?")
|
||||||
|
#define MRB_SYM_E_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "=")
|
||||||
|
#define MRB_SYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name)
|
||||||
|
|
||||||
|
#define MRB_OPSYM__not(mrb) MRB_PRESYM_SCANNING_TAGGED("!")
|
||||||
|
#define MRB_OPSYM__mod(mrb) MRB_PRESYM_SCANNING_TAGGED("%")
|
||||||
|
#define MRB_OPSYM__and(mrb) MRB_PRESYM_SCANNING_TAGGED("&")
|
||||||
|
#define MRB_OPSYM__mul(mrb) MRB_PRESYM_SCANNING_TAGGED("*")
|
||||||
|
#define MRB_OPSYM__add(mrb) MRB_PRESYM_SCANNING_TAGGED("+")
|
||||||
|
#define MRB_OPSYM__sub(mrb) MRB_PRESYM_SCANNING_TAGGED("-")
|
||||||
|
#define MRB_OPSYM__div(mrb) MRB_PRESYM_SCANNING_TAGGED("/")
|
||||||
|
#define MRB_OPSYM__lt(mrb) MRB_PRESYM_SCANNING_TAGGED("<")
|
||||||
|
#define MRB_OPSYM__gt(mrb) MRB_PRESYM_SCANNING_TAGGED(">")
|
||||||
|
#define MRB_OPSYM__xor(mrb) MRB_PRESYM_SCANNING_TAGGED("^")
|
||||||
|
#define MRB_OPSYM__tick(mrb) MRB_PRESYM_SCANNING_TAGGED("`")
|
||||||
|
#define MRB_OPSYM__or(mrb) MRB_PRESYM_SCANNING_TAGGED("|")
|
||||||
|
#define MRB_OPSYM__neg(mrb) MRB_PRESYM_SCANNING_TAGGED("~")
|
||||||
|
#define MRB_OPSYM__neq(mrb) MRB_PRESYM_SCANNING_TAGGED("!=")
|
||||||
|
#define MRB_OPSYM__nmatch(mrb) MRB_PRESYM_SCANNING_TAGGED("!~")
|
||||||
|
#define MRB_OPSYM__andand(mrb) MRB_PRESYM_SCANNING_TAGGED("&&")
|
||||||
|
#define MRB_OPSYM__pow(mrb) MRB_PRESYM_SCANNING_TAGGED("**")
|
||||||
|
#define MRB_OPSYM__plus(mrb) MRB_PRESYM_SCANNING_TAGGED("+@")
|
||||||
|
#define MRB_OPSYM__minus(mrb) MRB_PRESYM_SCANNING_TAGGED("-@")
|
||||||
|
#define MRB_OPSYM__lshift(mrb) MRB_PRESYM_SCANNING_TAGGED("<<")
|
||||||
|
#define MRB_OPSYM__le(mrb) MRB_PRESYM_SCANNING_TAGGED("<=")
|
||||||
|
#define MRB_OPSYM__eq(mrb) MRB_PRESYM_SCANNING_TAGGED("==")
|
||||||
|
#define MRB_OPSYM__match(mrb) MRB_PRESYM_SCANNING_TAGGED("=~")
|
||||||
|
#define MRB_OPSYM__ge(mrb) MRB_PRESYM_SCANNING_TAGGED(">=")
|
||||||
|
#define MRB_OPSYM__rshift(mrb) MRB_PRESYM_SCANNING_TAGGED(">>")
|
||||||
|
#define MRB_OPSYM__aref(mrb) MRB_PRESYM_SCANNING_TAGGED("[]")
|
||||||
|
#define MRB_OPSYM__oror(mrb) MRB_PRESYM_SCANNING_TAGGED("||")
|
||||||
|
#define MRB_OPSYM__cmp(mrb) MRB_PRESYM_SCANNING_TAGGED("<=>")
|
||||||
|
#define MRB_OPSYM__eqq(mrb) MRB_PRESYM_SCANNING_TAGGED("===")
|
||||||
|
#define MRB_OPSYM__aset(mrb) MRB_PRESYM_SCANNING_TAGGED("[]=")
|
||||||
|
|
||||||
|
#endif /* MRUBY_PRESYM_SCANNING_H */
|
||||||
+80
-13
@@ -41,10 +41,10 @@ void mrb_env_unshare(mrb_state*, struct REnv*);
|
|||||||
struct RProc {
|
struct RProc {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
union {
|
union {
|
||||||
mrb_irep *irep;
|
const mrb_irep *irep;
|
||||||
mrb_func_t func;
|
mrb_func_t func;
|
||||||
} body;
|
} body;
|
||||||
struct RProc *upper;
|
const struct RProc *upper;
|
||||||
union {
|
union {
|
||||||
struct RClass *target_class;
|
struct RClass *target_class;
|
||||||
struct REnv *env;
|
struct REnv *env;
|
||||||
@@ -57,7 +57,7 @@ struct RProc {
|
|||||||
#define MRB_ASPEC_REST(a) (((a) >> 12) & 0x1)
|
#define MRB_ASPEC_REST(a) (((a) >> 12) & 0x1)
|
||||||
#define MRB_ASPEC_POST(a) (((a) >> 7) & 0x1f)
|
#define MRB_ASPEC_POST(a) (((a) >> 7) & 0x1f)
|
||||||
#define MRB_ASPEC_KEY(a) (((a) >> 2) & 0x1f)
|
#define MRB_ASPEC_KEY(a) (((a) >> 2) & 0x1f)
|
||||||
#define MRB_ASPEC_KDICT(a) ((a) & (1<<1))
|
#define MRB_ASPEC_KDICT(a) (((a) >> 1) & 0x1)
|
||||||
#define MRB_ASPEC_BLOCK(a) ((a) & 1)
|
#define MRB_ASPEC_BLOCK(a) ((a) & 1)
|
||||||
|
|
||||||
#define MRB_PROC_CFUNC_FL 128
|
#define MRB_PROC_CFUNC_FL 128
|
||||||
@@ -86,16 +86,13 @@ struct RProc {
|
|||||||
|
|
||||||
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
|
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
|
||||||
|
|
||||||
struct RProc *mrb_proc_new(mrb_state*, mrb_irep*);
|
struct RProc *mrb_proc_new(mrb_state*, const mrb_irep*);
|
||||||
struct RProc *mrb_closure_new(mrb_state*, mrb_irep*);
|
struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
|
||||||
MRB_API struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
|
MRB_API struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
|
||||||
MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
|
MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
|
||||||
void mrb_proc_copy(struct RProc *a, struct RProc *b);
|
void mrb_proc_copy(struct RProc *a, struct RProc *b);
|
||||||
mrb_int mrb_proc_arity(const struct RProc *p);
|
mrb_int mrb_proc_arity(const struct RProc *p);
|
||||||
|
|
||||||
/* implementation of #send method */
|
|
||||||
mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
|
|
||||||
|
|
||||||
/* following functions are defined in mruby-proc-ext so please include it when using */
|
/* following functions are defined in mruby-proc-ext so please include it when using */
|
||||||
MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv);
|
MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv);
|
||||||
MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
||||||
@@ -104,10 +101,11 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
|||||||
|
|
||||||
#define MRB_METHOD_FUNC_FL 1
|
#define MRB_METHOD_FUNC_FL 1
|
||||||
#define MRB_METHOD_NOARG_FL 2
|
#define MRB_METHOD_NOARG_FL 2
|
||||||
#ifndef MRB_METHOD_T_STRUCT
|
|
||||||
|
#ifndef MRB_USE_METHOD_T_STRUCT
|
||||||
|
|
||||||
#define MRB_METHOD_FUNC_P(m) (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
|
#define MRB_METHOD_FUNC_P(m) (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
|
||||||
#define MRB_METHOD_NOARG_P(m) (((uintptr_t)(m))&MRB_METHOD_NOARG_FL)
|
#define MRB_METHOD_NOARG_P(m) ((((uintptr_t)(m))&MRB_METHOD_NOARG_FL)?1:0)
|
||||||
#define MRB_METHOD_NOARG_SET(m) ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))
|
#define MRB_METHOD_NOARG_SET(m) ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))
|
||||||
#define MRB_METHOD_FUNC(m) ((mrb_func_t)((uintptr_t)(m)>>2))
|
#define MRB_METHOD_FUNC(m) ((mrb_func_t)((uintptr_t)(m)>>2))
|
||||||
#define MRB_METHOD_FROM_FUNC(m,fn) ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))
|
#define MRB_METHOD_FROM_FUNC(m,fn) ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))
|
||||||
@@ -119,7 +117,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#define MRB_METHOD_FUNC_P(m) ((m).flags&MRB_METHOD_FUNC_FL)
|
#define MRB_METHOD_FUNC_P(m) ((m).flags&MRB_METHOD_FUNC_FL)
|
||||||
#define MRB_METHOD_NOARG_P(m) ((m).flags&MRB_METHOD_NOARG_FL)
|
#define MRB_METHOD_NOARG_P(m) (((m).flags&MRB_METHOD_NOARG_FL)?1:0)
|
||||||
#define MRB_METHOD_FUNC(m) ((m).func)
|
#define MRB_METHOD_FUNC(m) ((m).func)
|
||||||
#define MRB_METHOD_NOARG_SET(m) do{(m).flags|=MRB_METHOD_NOARG_FL;}while(0)
|
#define MRB_METHOD_NOARG_SET(m) do{(m).flags|=MRB_METHOD_NOARG_FL;}while(0)
|
||||||
#define MRB_METHOD_FROM_FUNC(m,fn) do{(m).flags=MRB_METHOD_FUNC_FL;(m).func=(fn);}while(0)
|
#define MRB_METHOD_FROM_FUNC(m,fn) do{(m).flags=MRB_METHOD_FUNC_FL;(m).func=(fn);}while(0)
|
||||||
@@ -128,14 +126,83 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
|||||||
#define MRB_METHOD_PROC(m) ((m).proc)
|
#define MRB_METHOD_PROC(m) ((m).proc)
|
||||||
#define MRB_METHOD_UNDEF_P(m) ((m).proc==NULL)
|
#define MRB_METHOD_UNDEF_P(m) ((m).proc==NULL)
|
||||||
|
|
||||||
#endif /* MRB_METHOD_T_STRUCT */
|
#endif /* MRB_USE_METHOD_T_STRUCT */
|
||||||
|
|
||||||
#define MRB_METHOD_CFUNC_P(m) (MRB_METHOD_FUNC_P(m)?TRUE:(MRB_METHOD_PROC(m)?(MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m))):FALSE))
|
#define MRB_METHOD_CFUNC_P(m) (MRB_METHOD_FUNC_P(m)?TRUE:(MRB_METHOD_PROC(m)?(MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m))):FALSE))
|
||||||
#define MRB_METHOD_CFUNC(m) (MRB_METHOD_FUNC_P(m)?MRB_METHOD_FUNC(m):((MRB_METHOD_PROC(m)&&MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m)))?MRB_PROC_CFUNC(MRB_METHOD_PROC(m)):NULL))
|
#define MRB_METHOD_CFUNC(m) (MRB_METHOD_FUNC_P(m)?MRB_METHOD_FUNC(m):((MRB_METHOD_PROC(m)&&MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m)))?MRB_PROC_CFUNC(MRB_METHOD_PROC(m)):NULL))
|
||||||
|
|
||||||
|
|
||||||
#include <mruby/khash.h>
|
#include <mruby/khash.h>
|
||||||
KHASH_DECLARE(mt, mrb_sym, mrb_method_t, TRUE)
|
|
||||||
|
MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc);
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p)
|
||||||
|
{
|
||||||
|
ci->proc = p;
|
||||||
|
ci->pc = (p && !MRB_PROC_CFUNC_P(p)) ? p->body.irep->iseq : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct RClass *
|
||||||
|
mrb_vm_ci_target_class(const mrb_callinfo *ci)
|
||||||
|
{
|
||||||
|
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
|
||||||
|
return ci->u.env->c;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ci->u.target_class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc)
|
||||||
|
{
|
||||||
|
struct REnv *e = ci->u.env;
|
||||||
|
if (e) {
|
||||||
|
if (e->tt == MRB_TT_ENV) {
|
||||||
|
e->c = tc;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ci->u.target_class = tc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct REnv *
|
||||||
|
mrb_vm_ci_env(const mrb_callinfo *ci)
|
||||||
|
{
|
||||||
|
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
|
||||||
|
return ci->u.env;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
mrb_vm_ci_env_set(mrb_callinfo *ci, struct REnv *e)
|
||||||
|
{
|
||||||
|
if (ci->u.env) {
|
||||||
|
if (ci->u.env->tt == MRB_TT_ENV) {
|
||||||
|
if (e) {
|
||||||
|
e->c = ci->u.env->c;
|
||||||
|
ci->u.env = e;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ci->u.target_class = ci->u.env->c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (e) {
|
||||||
|
e->c = ci->u.target_class;
|
||||||
|
ci->u.env = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ci->u.env = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MRB_END_DECL
|
MRB_END_DECL
|
||||||
|
|
||||||
|
|||||||
+10
-15
@@ -35,7 +35,7 @@ struct RString {
|
|||||||
};
|
};
|
||||||
struct RStringEmbed {
|
struct RStringEmbed {
|
||||||
MRB_OBJECT_HEADER;
|
MRB_OBJECT_HEADER;
|
||||||
char ary[];
|
char ary[RSTRING_EMBED_LEN_MAX+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
|
#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
|
||||||
@@ -92,9 +92,6 @@ struct RStringEmbed {
|
|||||||
# define RSTR_COPY_ASCII_FLAG(dst, src) (void)0
|
# define RSTR_COPY_ASCII_FLAG(dst, src) (void)0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RSTR_POOL_P(s) ((s)->flags & MRB_STR_POOL)
|
|
||||||
#define RSTR_SET_POOL_FLAG(s) ((s)->flags |= MRB_STR_POOL)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer from a Ruby string
|
* Returns a pointer from a Ruby string
|
||||||
*/
|
*/
|
||||||
@@ -112,13 +109,11 @@ MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
|
|||||||
#define MRB_STR_FSHARED 2
|
#define MRB_STR_FSHARED 2
|
||||||
#define MRB_STR_NOFREE 4
|
#define MRB_STR_NOFREE 4
|
||||||
#define MRB_STR_EMBED 8 /* type flags up to here */
|
#define MRB_STR_EMBED 8 /* type flags up to here */
|
||||||
#define MRB_STR_POOL 16 /* status flags from here */
|
#define MRB_STR_ASCII 16
|
||||||
#define MRB_STR_ASCII 32
|
|
||||||
#define MRB_STR_EMBED_LEN_SHIFT 6
|
#define MRB_STR_EMBED_LEN_SHIFT 6
|
||||||
#define MRB_STR_EMBED_LEN_BIT 5
|
#define MRB_STR_EMBED_LEN_BIT 5
|
||||||
#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BIT) - 1) << MRB_STR_EMBED_LEN_SHIFT)
|
#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BIT) - 1) << MRB_STR_EMBED_LEN_SHIFT)
|
||||||
#define MRB_STR_TYPE_MASK (MRB_STR_POOL - 1)
|
#define MRB_STR_TYPE_MASK 15
|
||||||
|
|
||||||
|
|
||||||
void mrb_gc_free_str(mrb_state*, struct RString*);
|
void mrb_gc_free_str(mrb_state*, struct RString*);
|
||||||
|
|
||||||
@@ -164,7 +159,7 @@ MRB_API mrb_int mrb_str_index(mrb_state *mrb, mrb_value str, const char *p, mrb_
|
|||||||
*
|
*
|
||||||
* mrb_close(mrb);
|
* mrb_close(mrb);
|
||||||
* return 0;
|
* return 0;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Result:
|
* Result:
|
||||||
*
|
*
|
||||||
@@ -344,15 +339,15 @@ MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
|
|||||||
|
|
||||||
|
|
||||||
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
|
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
|
||||||
MRB_API mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);
|
#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
|
||||||
|
|
||||||
/* NULL terminated C string from mrb_value */
|
/* NULL terminated C string from mrb_value */
|
||||||
MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
|
MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
|
||||||
/* NULL terminated C string from mrb_value; `str` will be updated */
|
/* NULL terminated C string from mrb_value; `str` will be updated */
|
||||||
MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
|
MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
|
||||||
/* obslete: use RSTRING_PTR() */
|
/* obsolete: use RSTRING_PTR() */
|
||||||
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
|
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
|
||||||
/* obslete: use RSTRING_LEN() */
|
/* obsolete: use RSTRING_LEN() */
|
||||||
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
|
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -382,8 +377,9 @@ MRB_API double mrb_cstr_to_dbl(mrb_state *mrb, const char *s, mrb_bool badcheck)
|
|||||||
/**
|
/**
|
||||||
* Returns a converted string type.
|
* Returns a converted string type.
|
||||||
* For type checking, non converting `mrb_to_str` is recommended.
|
* For type checking, non converting `mrb_to_str` is recommended.
|
||||||
|
* obsolete: use `mrb_obj_as_string()` instead.
|
||||||
*/
|
*/
|
||||||
MRB_API mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
|
#define mrb_str_to_str(mrb, str) mrb_obj_as_string(mrb, str)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the strings match and false if the strings don't match.
|
* Returns true if the strings match and false if the strings don't match.
|
||||||
@@ -437,7 +433,7 @@ MRB_API int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
|
|||||||
* - Returned string does not contain any NUL characters (but terminator).
|
* - Returned string does not contain any NUL characters (but terminator).
|
||||||
* - It raises an ArgumentError exception if Ruby string contains
|
* - It raises an ArgumentError exception if Ruby string contains
|
||||||
* NUL characters.
|
* NUL characters.
|
||||||
* - Retured string will be freed automatically on next GC.
|
* - Returned string will be freed automatically on next GC.
|
||||||
* - Caller can modify returned string without affecting Ruby string
|
* - Caller can modify returned string without affecting Ruby string
|
||||||
* (e.g. it can be used for mkstemp(3)).
|
* (e.g. it can be used for mkstemp(3)).
|
||||||
*
|
*
|
||||||
@@ -447,7 +443,6 @@ MRB_API int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
|
|||||||
*/
|
*/
|
||||||
MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
|
MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
|
||||||
|
|
||||||
mrb_value mrb_str_pool(mrb_state *mrb, const char *s, mrb_int len, mrb_bool nofree);
|
|
||||||
uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
|
uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
|
||||||
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
|
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
|
||||||
|
|
||||||
|
|||||||
+14
-3
@@ -7,13 +7,15 @@
|
|||||||
#ifndef MRB_THROW_H
|
#ifndef MRB_THROW_H
|
||||||
#define MRB_THROW_H
|
#define MRB_THROW_H
|
||||||
|
|
||||||
#if defined(MRB_ENABLE_CXX_ABI)
|
#if defined(MRB_USE_CXX_ABI)
|
||||||
# if !defined(__cplusplus)
|
# if !defined(__cplusplus)
|
||||||
# error Trying to use C++ exception handling in C code
|
# error Trying to use C++ exception handling in C code
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||||
|
|
||||||
|
# if defined(__cplusplus)
|
||||||
|
|
||||||
#define MRB_TRY(buf) try {
|
#define MRB_TRY(buf) try {
|
||||||
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
|
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
|
||||||
@@ -22,6 +24,10 @@
|
|||||||
#define MRB_THROW(buf) throw((buf)->impl)
|
#define MRB_THROW(buf) throw((buf)->impl)
|
||||||
typedef mrb_int mrb_jmpbuf_impl;
|
typedef mrb_int mrb_jmpbuf_impl;
|
||||||
|
|
||||||
|
# else
|
||||||
|
# error "need to be compiled with C++ compiler"
|
||||||
|
# endif /* __cplusplus */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -29,6 +35,9 @@ typedef mrb_int mrb_jmpbuf_impl;
|
|||||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
#define MRB_SETJMP _setjmp
|
#define MRB_SETJMP _setjmp
|
||||||
#define MRB_LONGJMP _longjmp
|
#define MRB_LONGJMP _longjmp
|
||||||
|
#elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
|
||||||
|
#define MRB_SETJMP __builtin_setjmp
|
||||||
|
#define MRB_LONGJMP __builtin_longjmp
|
||||||
#else
|
#else
|
||||||
#define MRB_SETJMP setjmp
|
#define MRB_SETJMP setjmp
|
||||||
#define MRB_LONGJMP longjmp
|
#define MRB_LONGJMP longjmp
|
||||||
@@ -46,9 +55,11 @@ typedef mrb_int mrb_jmpbuf_impl;
|
|||||||
struct mrb_jmpbuf {
|
struct mrb_jmpbuf {
|
||||||
mrb_jmpbuf_impl impl;
|
mrb_jmpbuf_impl impl;
|
||||||
|
|
||||||
#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
|
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||||
static mrb_int jmpbuf_id;
|
static mrb_int jmpbuf_id;
|
||||||
|
# if defined(__cplusplus)
|
||||||
mrb_jmpbuf() : impl(jmpbuf_id++) {}
|
mrb_jmpbuf() : impl(jmpbuf_id++) {}
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+29
-19
@@ -53,17 +53,19 @@ struct mrb_state;
|
|||||||
|
|
||||||
#if defined(MRB_INT64)
|
#if defined(MRB_INT64)
|
||||||
typedef int64_t mrb_int;
|
typedef int64_t mrb_int;
|
||||||
|
typedef uint64_t mrb_uint;
|
||||||
# define MRB_INT_BIT 64
|
# define MRB_INT_BIT 64
|
||||||
# define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
|
# define MRB_INT_MIN INT64_MIN
|
||||||
# define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
|
# define MRB_INT_MAX INT64_MAX
|
||||||
# define MRB_PRIo PRIo64
|
# define MRB_PRIo PRIo64
|
||||||
# define MRB_PRId PRId64
|
# define MRB_PRId PRId64
|
||||||
# define MRB_PRIx PRIx64
|
# define MRB_PRIx PRIx64
|
||||||
#else
|
#else
|
||||||
typedef int32_t mrb_int;
|
typedef int32_t mrb_int;
|
||||||
|
typedef uint32_t mrb_uint;
|
||||||
# define MRB_INT_BIT 32
|
# define MRB_INT_BIT 32
|
||||||
# define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
|
# define MRB_INT_MIN INT32_MIN
|
||||||
# define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
|
# define MRB_INT_MAX INT32_MAX
|
||||||
# define MRB_PRIo PRIo32
|
# define MRB_PRIo PRIo32
|
||||||
# define MRB_PRId PRId32
|
# define MRB_PRId PRId32
|
||||||
# define MRB_PRIx PRIx32
|
# define MRB_PRIx PRIx32
|
||||||
@@ -75,9 +77,9 @@ struct mrb_state;
|
|||||||
# define MRB_ENDIAN_LOHI(a,b) b a
|
# define MRB_ENDIAN_LOHI(a,b) b a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
MRB_API double mrb_float_read(const char*, char**);
|
MRB_API double mrb_float_read(const char*, char**);
|
||||||
#ifdef MRB_USE_FLOAT
|
#ifdef MRB_USE_FLOAT32
|
||||||
typedef float mrb_float;
|
typedef float mrb_float;
|
||||||
#else
|
#else
|
||||||
typedef double mrb_float;
|
typedef double mrb_float;
|
||||||
@@ -90,7 +92,7 @@ MRB_API int mrb_msvc_vsnprintf(char *s, size_t n, const char *format, va_list ar
|
|||||||
MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
|
MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
|
||||||
# define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
|
# define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
|
||||||
# define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
|
# define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
|
||||||
# if _MSC_VER < 1800 && !defined MRB_WITHOUT_FLOAT
|
# if _MSC_VER < 1800 && !defined MRB_NO_FLOAT
|
||||||
# include <float.h>
|
# include <float.h>
|
||||||
# define isfinite(n) _finite(n)
|
# define isfinite(n) _finite(n)
|
||||||
# define isnan _isnan
|
# define isnan _isnan
|
||||||
@@ -106,7 +108,7 @@ enum mrb_vtype {
|
|||||||
MRB_TT_FALSE = 0,
|
MRB_TT_FALSE = 0,
|
||||||
MRB_TT_TRUE,
|
MRB_TT_TRUE,
|
||||||
MRB_TT_FLOAT,
|
MRB_TT_FLOAT,
|
||||||
MRB_TT_FIXNUM,
|
MRB_TT_INTEGER,
|
||||||
MRB_TT_SYMBOL,
|
MRB_TT_SYMBOL,
|
||||||
MRB_TT_UNDEF,
|
MRB_TT_UNDEF,
|
||||||
MRB_TT_CPTR,
|
MRB_TT_CPTR,
|
||||||
@@ -130,6 +132,9 @@ enum mrb_vtype {
|
|||||||
MRB_TT_MAXDEFINE
|
MRB_TT_MAXDEFINE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* for compatibility */
|
||||||
|
#define MRB_TT_FIXNUM MRB_TT_INTEGER
|
||||||
|
|
||||||
#include <mruby/object.h>
|
#include <mruby/object.h>
|
||||||
|
|
||||||
#ifdef MRB_DOCUMENTATION_BLOCK
|
#ifdef MRB_DOCUMENTATION_BLOCK
|
||||||
@@ -163,12 +168,9 @@ struct RCptr {
|
|||||||
#include "boxing_no.h"
|
#include "boxing_no.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MRB_SYMBOL_BIT (sizeof(mrb_sym) * CHAR_BIT - MRB_SYMBOL_SHIFT)
|
|
||||||
#define MRB_SYMBOL_MAX (UINT32_MAX >> MRB_SYMBOL_SHIFT)
|
|
||||||
|
|
||||||
#if INTPTR_MAX < MRB_INT_MAX
|
#if INTPTR_MAX < MRB_INT_MAX
|
||||||
typedef intptr_t mrb_ssize;
|
typedef intptr_t mrb_ssize;
|
||||||
# define MRB_SSIZE_MAX (INTPTR_MAX>>MRB_FIXNUM_SHIFT)
|
# define MRB_SSIZE_MAX INTPTR_MAX
|
||||||
#else
|
#else
|
||||||
typedef mrb_int mrb_ssize;
|
typedef mrb_int mrb_ssize;
|
||||||
# define MRB_SSIZE_MAX MRB_INT_MAX
|
# define MRB_SSIZE_MAX MRB_INT_MAX
|
||||||
@@ -177,8 +179,11 @@ struct RCptr {
|
|||||||
#ifndef mrb_immediate_p
|
#ifndef mrb_immediate_p
|
||||||
#define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
|
#define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef mrb_integer_p
|
||||||
|
#define mrb_integer_p(o) (mrb_type(o) == MRB_TT_INTEGER)
|
||||||
|
#endif
|
||||||
#ifndef mrb_fixnum_p
|
#ifndef mrb_fixnum_p
|
||||||
#define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
|
#define mrb_fixnum_p(o) mrb_integer_p(o)
|
||||||
#endif
|
#endif
|
||||||
#ifndef mrb_symbol_p
|
#ifndef mrb_symbol_p
|
||||||
#define mrb_symbol_p(o) (mrb_type(o) == MRB_TT_SYMBOL)
|
#define mrb_symbol_p(o) (mrb_type(o) == MRB_TT_SYMBOL)
|
||||||
@@ -195,7 +200,7 @@ struct RCptr {
|
|||||||
#ifndef mrb_true_p
|
#ifndef mrb_true_p
|
||||||
#define mrb_true_p(o) (mrb_type(o) == MRB_TT_TRUE)
|
#define mrb_true_p(o) (mrb_type(o) == MRB_TT_TRUE)
|
||||||
#endif
|
#endif
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
#ifndef mrb_float_p
|
#ifndef mrb_float_p
|
||||||
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
|
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
|
||||||
#endif
|
#endif
|
||||||
@@ -264,7 +269,7 @@ struct RCptr {
|
|||||||
*
|
*
|
||||||
* Takes a float and boxes it into an mrb_value
|
* Takes a float and boxes it into an mrb_value
|
||||||
*/
|
*/
|
||||||
#ifndef MRB_WITHOUT_FLOAT
|
#ifndef MRB_NO_FLOAT
|
||||||
MRB_INLINE mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
|
MRB_INLINE mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
|
||||||
{
|
{
|
||||||
mrb_value v;
|
mrb_value v;
|
||||||
@@ -284,14 +289,19 @@ mrb_cptr_value(struct mrb_state *mrb, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a fixnum in Ruby.
|
* Returns an integer in Ruby.
|
||||||
*
|
|
||||||
* Takes an integer and boxes it into an mrb_value
|
|
||||||
*/
|
*/
|
||||||
|
MRB_INLINE mrb_value mrb_int_value(struct mrb_state *mrb, mrb_int i)
|
||||||
|
{
|
||||||
|
mrb_value v;
|
||||||
|
SET_INT_VALUE(mrb, v, i);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
MRB_INLINE mrb_value mrb_fixnum_value(mrb_int i)
|
MRB_INLINE mrb_value mrb_fixnum_value(mrb_int i)
|
||||||
{
|
{
|
||||||
mrb_value v;
|
mrb_value v;
|
||||||
SET_INT_VALUE(v, i);
|
SET_FIXNUM_VALUE(v, i);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
|
|||||||
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
|
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
|
||||||
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
|
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
|
||||||
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
|
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
|
||||||
|
size_t mrb_obj_iv_tbl_memsize(mrb_value);
|
||||||
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
|
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
|
||||||
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
|
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
|
||||||
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
|
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
|
||||||
|
|||||||
+26
-7
@@ -27,7 +27,7 @@ MRB_BEGIN_DECL
|
|||||||
/*
|
/*
|
||||||
* The version of Ruby used by mruby.
|
* The version of Ruby used by mruby.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RUBY_VERSION "2.0"
|
#define MRUBY_RUBY_VERSION "3.0"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ruby engine.
|
* Ruby engine.
|
||||||
@@ -37,17 +37,35 @@ MRB_BEGIN_DECL
|
|||||||
/*
|
/*
|
||||||
* Major release version number.
|
* Major release version number.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_MAJOR 2
|
#define MRUBY_RELEASE_MAJOR 3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Minor release version number.
|
* Minor release version number.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_MINOR 1
|
#define MRUBY_RELEASE_MINOR 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tiny release version number.
|
* Tiny release version number.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_TEENY 2
|
#define MRUBY_RELEASE_TEENY 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Patch level.
|
||||||
|
*/
|
||||||
|
#define MRUBY_PATCHLEVEL -1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Patch level string. (optional)
|
||||||
|
*/
|
||||||
|
#define MRUBY_PATCHLEVEL_STR ""
|
||||||
|
|
||||||
|
#ifndef MRUBY_PATCHLEVEL_STR
|
||||||
|
# if MRUBY_PATCHLEVEL < 0
|
||||||
|
# define MRUBY_PATCHLEVEL_STR "dev"
|
||||||
|
# else
|
||||||
|
# define MRUBY_PATCHLEVEL_STR "p"MRB_STRINGIZE(MRUBY_PATCHLEVEL)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The mruby version.
|
* The mruby version.
|
||||||
@@ -62,17 +80,17 @@ MRB_BEGIN_DECL
|
|||||||
/*
|
/*
|
||||||
* Release year.
|
* Release year.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_YEAR 2020
|
#define MRUBY_RELEASE_YEAR 2021
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release month.
|
* Release month.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_MONTH 8
|
#define MRUBY_RELEASE_MONTH 3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release day.
|
* Release day.
|
||||||
*/
|
*/
|
||||||
#define MRUBY_RELEASE_DAY 6
|
#define MRUBY_RELEASE_DAY 5
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release date as a string.
|
* Release date as a string.
|
||||||
@@ -108,6 +126,7 @@ MRB_BEGIN_DECL
|
|||||||
*/
|
*/
|
||||||
#define MRUBY_DESCRIPTION \
|
#define MRUBY_DESCRIPTION \
|
||||||
"mruby " MRUBY_VERSION \
|
"mruby " MRUBY_VERSION \
|
||||||
|
MRUBY_PATCHLEVEL_STR \
|
||||||
" (" MRUBY_RELEASE_DATE ")" \
|
" (" MRUBY_RELEASE_DATE ")" \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+198
-44
@@ -1,10 +1,11 @@
|
|||||||
require "mruby-core-ext"
|
require "mruby/core_ext"
|
||||||
require "mruby/build/load_gems"
|
require "mruby/build/load_gems"
|
||||||
require "mruby/build/command"
|
require "mruby/build/command"
|
||||||
|
|
||||||
module MRuby
|
module MRuby
|
||||||
autoload :Gem, "mruby/gem"
|
autoload :Gem, "mruby/gem"
|
||||||
autoload :Lockfile, "mruby/lockfile"
|
autoload :Lockfile, "mruby/lockfile"
|
||||||
|
autoload :Presym, "mruby/presym"
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def targets
|
def targets
|
||||||
@@ -22,6 +23,18 @@ module MRuby
|
|||||||
class Toolchain
|
class Toolchain
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :toolchains
|
attr_accessor :toolchains
|
||||||
|
|
||||||
|
def guess
|
||||||
|
if cc = ENV["CC"] || ENV["CXX"]
|
||||||
|
return "clang" if cc.include?("clang")
|
||||||
|
else
|
||||||
|
return "clang" if RUBY_PLATFORM =~ /darwin|(?:free|open)bsd/
|
||||||
|
return "gcc" if RUBY_PLATFORM.include?("cygwin")
|
||||||
|
return "visualcpp" if ENV.include?("VisualStudioVersion")
|
||||||
|
return "visualcpp" if ENV.include?("VSINSTALLDIR")
|
||||||
|
end
|
||||||
|
"gcc"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(name, &block)
|
def initialize(name, &block)
|
||||||
@@ -29,7 +42,7 @@ module MRuby
|
|||||||
MRuby::Toolchain.toolchains[@name] = self
|
MRuby::Toolchain.toolchains[@name] = self
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup(conf,params={})
|
def setup(conf, params={})
|
||||||
conf.instance_exec(conf, params, &@initializer)
|
conf.instance_exec(conf, params, &@initializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,12 +52,27 @@ module MRuby
|
|||||||
class Build
|
class Build
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :current
|
attr_accessor :current
|
||||||
|
|
||||||
|
def mruby_config_path
|
||||||
|
path = ENV['MRUBY_CONFIG'] || ENV['CONFIG']
|
||||||
|
if path.nil? || path.empty?
|
||||||
|
path = "#{MRUBY_ROOT}/build_config/default.rb"
|
||||||
|
elsif !File.file?(path) && !Pathname.new(path).absolute?
|
||||||
|
f = "#{MRUBY_ROOT}/build_config/#{path}.rb"
|
||||||
|
path = File.exist?(f) ? f : File.extname(path).empty? ? f : path
|
||||||
|
end
|
||||||
|
path
|
||||||
|
end
|
||||||
|
|
||||||
|
def install_dir
|
||||||
|
@install_dir ||= ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
include Rake::DSL
|
include Rake::DSL
|
||||||
include LoadGems
|
include LoadGems
|
||||||
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
|
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
|
||||||
attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url
|
attr_reader :products, :libmruby_core_objs, :libmruby_objs, :gems, :toolchains, :presym, :mrbc_build, :gem_dir_to_repo_url
|
||||||
attr_writer :enable_bintest, :enable_test
|
|
||||||
|
|
||||||
alias libmruby libmruby_objs
|
alias libmruby libmruby_objs
|
||||||
|
|
||||||
@@ -52,16 +80,16 @@ module MRuby
|
|||||||
COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
|
COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
|
||||||
attr_block MRuby::Build::COMMANDS
|
attr_block MRuby::Build::COMMANDS
|
||||||
|
|
||||||
Exts = Struct.new(:object, :executable, :library)
|
Exts = Struct.new(:object, :executable, :library, :presym_preprocessed)
|
||||||
|
|
||||||
def initialize(name='host', build_dir=nil, &block)
|
def initialize(name='host', build_dir=nil, internal: false, &block)
|
||||||
@name = name.to_s
|
@name = name.to_s
|
||||||
|
|
||||||
unless MRuby.targets[@name]
|
unless current = MRuby.targets[@name]
|
||||||
if ENV['OS'] == 'Windows_NT'
|
if ENV['OS'] == 'Windows_NT'
|
||||||
@exts = Exts.new('.o', '.exe', '.a')
|
@exts = Exts.new('.o', '.exe', '.a', '.pi')
|
||||||
else
|
else
|
||||||
@exts = Exts.new('.o', '', '.a')
|
@exts = Exts.new('.o', '', '.a', '.pi')
|
||||||
end
|
end
|
||||||
|
|
||||||
build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
|
build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
|
||||||
@@ -69,10 +97,10 @@ module MRuby
|
|||||||
@file_separator = '/'
|
@file_separator = '/'
|
||||||
@build_dir = "#{build_dir}/#{@name}"
|
@build_dir = "#{build_dir}/#{@name}"
|
||||||
@gem_clone_dir = "#{build_dir}/repos/#{@name}"
|
@gem_clone_dir = "#{build_dir}/repos/#{@name}"
|
||||||
@cc = Command::Compiler.new(self, %w(.c))
|
@cc = Command::Compiler.new(self, %w(.c), label: "CC")
|
||||||
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
|
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp), label: "CXX")
|
||||||
@objc = Command::Compiler.new(self, %w(.m))
|
@objc = Command::Compiler.new(self, %w(.m), label: "OBJC")
|
||||||
@asm = Command::Compiler.new(self, %w(.S .asm))
|
@asm = Command::Compiler.new(self, %w(.S .asm .s), label: "ASM")
|
||||||
@linker = Command::Linker.new(self)
|
@linker = Command::Linker.new(self)
|
||||||
@archiver = Command::Archiver.new(self)
|
@archiver = Command::Archiver.new(self)
|
||||||
@yacc = Command::Yacc.new(self)
|
@yacc = Command::Yacc.new(self)
|
||||||
@@ -80,8 +108,12 @@ module MRuby
|
|||||||
@git = Command::Git.new(self)
|
@git = Command::Git.new(self)
|
||||||
@mrbc = Command::Mrbc.new(self)
|
@mrbc = Command::Mrbc.new(self)
|
||||||
|
|
||||||
|
@products = []
|
||||||
@bins = []
|
@bins = []
|
||||||
@gems, @libmruby_objs = MRuby::Gem::List.new, []
|
@gems = MRuby::Gem::List.new
|
||||||
|
@libmruby_core_objs = []
|
||||||
|
@libmruby_objs = [@libmruby_core_objs]
|
||||||
|
@enable_libmruby = true
|
||||||
@build_mrbtest_lib_only = false
|
@build_mrbtest_lib_only = false
|
||||||
@cxx_exception_enabled = false
|
@cxx_exception_enabled = false
|
||||||
@cxx_exception_disabled = false
|
@cxx_exception_disabled = false
|
||||||
@@ -89,17 +121,33 @@ module MRuby
|
|||||||
@enable_bintest = false
|
@enable_bintest = false
|
||||||
@enable_test = false
|
@enable_test = false
|
||||||
@enable_lock = true
|
@enable_lock = true
|
||||||
|
@enable_presym = true
|
||||||
|
@mrbcfile_external = false
|
||||||
|
@internal = internal
|
||||||
@toolchains = []
|
@toolchains = []
|
||||||
@gem_dir_to_repo_url = {}
|
@gem_dir_to_repo_url = {}
|
||||||
|
|
||||||
MRuby.targets[@name] = self
|
MRuby.targets[@name] = current = self
|
||||||
end
|
end
|
||||||
|
|
||||||
MRuby::Build.current = MRuby.targets[@name]
|
MRuby::Build.current = current
|
||||||
MRuby.targets[@name].instance_eval(&block)
|
current.instance_eval(&block)
|
||||||
|
if current.libmruby_enabled? && !current.mrbcfile_external?
|
||||||
|
if current.presym_enabled?
|
||||||
|
current.create_mrbc_build if current.host? || current.gems["mruby-bin-mrbc"]
|
||||||
|
elsif current.host?
|
||||||
|
current.build_mrbc_exec
|
||||||
|
end
|
||||||
|
end
|
||||||
|
current.presym = Presym.new(current) if current.presym_enabled?
|
||||||
|
end
|
||||||
|
|
||||||
build_mrbc_exec if name == 'host'
|
def libmruby_enabled?
|
||||||
build_mrbtest if test_enabled?
|
@enable_libmruby
|
||||||
|
end
|
||||||
|
|
||||||
|
def disable_libmruby
|
||||||
|
@enable_libmruby = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def debug_enabled?
|
def debug_enabled?
|
||||||
@@ -118,6 +166,17 @@ module MRuby
|
|||||||
@enable_debug = true
|
@enable_debug = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def presym_enabled?
|
||||||
|
@enable_presym
|
||||||
|
end
|
||||||
|
|
||||||
|
def disable_presym
|
||||||
|
if @enable_presym
|
||||||
|
@enable_presym = false
|
||||||
|
compilers.each{|c| c.defines << "MRB_NO_PRESYM"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def disable_lock
|
def disable_lock
|
||||||
@enable_lock = false
|
@enable_lock = false
|
||||||
end
|
end
|
||||||
@@ -141,7 +200,7 @@ module MRuby
|
|||||||
end
|
end
|
||||||
@cxx_exception_enabled = true
|
@cxx_exception_enabled = true
|
||||||
compilers.each { |c|
|
compilers.each { |c|
|
||||||
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION)
|
c.defines += %w(MRB_USE_CXX_EXCEPTION)
|
||||||
c.flags << c.cxx_exception_flag
|
c.flags << c.cxx_exception_flag
|
||||||
}
|
}
|
||||||
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
|
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
|
||||||
@@ -161,7 +220,7 @@ module MRuby
|
|||||||
raise "cxx_exception already enabled"
|
raise "cxx_exception already enabled"
|
||||||
end
|
end
|
||||||
compilers.each { |c|
|
compilers.each { |c|
|
||||||
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI)
|
c.defines += %w(MRB_USE_CXX_EXCEPTION MRB_USE_CXX_ABI)
|
||||||
c.flags << c.cxx_compile_flag
|
c.flags << c.cxx_compile_flag
|
||||||
c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten
|
c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten
|
||||||
}
|
}
|
||||||
@@ -169,8 +228,29 @@ module MRuby
|
|||||||
@cxx_abi_enabled = true
|
@cxx_abi_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile_as_cxx src, cxx_src, obj = nil, includes = []
|
def compile_as_cxx(src, cxx_src = nil, obj = nil, includes = [])
|
||||||
obj = objfile(cxx_src) if obj.nil?
|
#
|
||||||
|
# If `cxx_src` is specified, this method behaves the same as before as
|
||||||
|
# compatibility mode, but `.d` file is not read.
|
||||||
|
#
|
||||||
|
# If `cxx_src` is omitted, `.d` file is read by using mruby standard
|
||||||
|
# Rake rule (C++ source name is also changed).
|
||||||
|
#
|
||||||
|
if cxx_src
|
||||||
|
obj ||= cxx_src + @exts.object
|
||||||
|
dsts = [obj]
|
||||||
|
dsts << (cxx_src + @exts.presym_preprocessed) if presym_enabled?
|
||||||
|
defines = []
|
||||||
|
include_paths = ["#{MRUBY_ROOT}/src", *includes]
|
||||||
|
dsts.each do |dst|
|
||||||
|
file dst => cxx_src do |t|
|
||||||
|
cxx.run t.name, t.prerequisites.first, defines, include_paths
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cxx_src = "#{build_dir}/#{src.relative_path})".ext << "-cxx.cxx"
|
||||||
|
obj = cxx_src.ext(@exts.object)
|
||||||
|
end
|
||||||
|
|
||||||
file cxx_src => [src, __FILE__] do |t|
|
file cxx_src => [src, __FILE__] do |t|
|
||||||
mkdir_p File.dirname t.name
|
mkdir_p File.dirname t.name
|
||||||
@@ -178,20 +258,16 @@ module MRuby
|
|||||||
#define __STDC_CONSTANT_MACROS
|
#define __STDC_CONSTANT_MACROS
|
||||||
#define __STDC_LIMIT_MACROS
|
#define __STDC_LIMIT_MACROS
|
||||||
|
|
||||||
#ifndef MRB_ENABLE_CXX_ABI
|
#ifndef MRB_USE_CXX_ABI
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "#{File.absolute_path src}"
|
#include "#{File.absolute_path src}"
|
||||||
#ifndef MRB_ENABLE_CXX_ABI
|
#ifndef MRB_USE_CXX_ABI
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
file obj => cxx_src do |t|
|
|
||||||
cxx.run t.name, t.prerequisites.first, [], ["#{MRUBY_ROOT}/src"] + includes
|
|
||||||
end
|
|
||||||
|
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -203,7 +279,7 @@ EOS
|
|||||||
@enable_bintest
|
@enable_bintest
|
||||||
end
|
end
|
||||||
|
|
||||||
def toolchain(name, params={})
|
def toolchain(name=Toolchain.guess, params={})
|
||||||
name = name.to_s
|
name = name.to_s
|
||||||
tc = Toolchain.toolchains[name] || begin
|
tc = Toolchain.toolchains[name] || begin
|
||||||
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
|
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
|
||||||
@@ -226,17 +302,14 @@ EOS
|
|||||||
def enable_test
|
def enable_test
|
||||||
@enable_test = true
|
@enable_test = true
|
||||||
end
|
end
|
||||||
|
alias build_mrbtest enable_test
|
||||||
|
|
||||||
def test_enabled?
|
def test_enabled?
|
||||||
@enable_test
|
@enable_test
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_mrbtest
|
|
||||||
gem :core => 'mruby-test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_mrbc_exec
|
def build_mrbc_exec
|
||||||
gem :core => 'mruby-bin-mrbc'
|
gem :core => 'mruby-bin-mrbc' unless @gems['mruby-bin-mrbc']
|
||||||
end
|
end
|
||||||
|
|
||||||
def locks
|
def locks
|
||||||
@@ -246,9 +319,22 @@ EOS
|
|||||||
def mrbcfile
|
def mrbcfile
|
||||||
return @mrbcfile if @mrbcfile
|
return @mrbcfile if @mrbcfile
|
||||||
|
|
||||||
mrbc_build = MRuby.targets['host']
|
gem_name = "mruby-bin-mrbc"
|
||||||
gems.each { |v| mrbc_build = self if v.name == 'mruby-bin-mrbc' }
|
gem = @gems[gem_name]
|
||||||
@mrbcfile = mrbc_build.exefile("#{mrbc_build.build_dir}/bin/mrbc")
|
gem ||= (host = MRuby.targets["host"]) && host.gems[gem_name]
|
||||||
|
unless gem
|
||||||
|
fail "external mrbc or mruby-bin-mrbc gem in current('#{@name}') or 'host' build is required"
|
||||||
|
end
|
||||||
|
@mrbcfile = exefile("#{gem.build.build_dir}/bin/mrbc")
|
||||||
|
end
|
||||||
|
|
||||||
|
def mrbcfile=(path)
|
||||||
|
@mrbcfile = path
|
||||||
|
@mrbcfile_external = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def mrbcfile_external?
|
||||||
|
@mrbcfile_external
|
||||||
end
|
end
|
||||||
|
|
||||||
def compilers
|
def compilers
|
||||||
@@ -258,14 +344,32 @@ EOS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def define_rules
|
def define_rules
|
||||||
|
use_mrdb = @gems["mruby-bin-debugger"]
|
||||||
compilers.each do |compiler|
|
compilers.each do |compiler|
|
||||||
if respond_to?(:enable_gems?) && enable_gems?
|
if respond_to?(:enable_gems?) && enable_gems?
|
||||||
compiler.defines -= %w(DISABLE_GEMS)
|
compiler.defines -= %w(MRB_NO_GEMS)
|
||||||
else
|
else
|
||||||
compiler.defines += %w(DISABLE_GEMS)
|
compiler.defines += %w(MRB_NO_GEMS)
|
||||||
end
|
end
|
||||||
compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
compiler.defines |= %w(MRB_USE_DEBUG_HOOK) if use_mrdb
|
||||||
end
|
end
|
||||||
|
[@cc, *(@cxx if cxx_exception_enabled?)].each do |compiler|
|
||||||
|
compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.object)
|
||||||
|
compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.presym_preprocessed) if presym_enabled?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def define_installer(src)
|
||||||
|
dst = "#{self.class.install_dir}/#{File.basename(src)}"
|
||||||
|
file dst => src do
|
||||||
|
install_D src, dst
|
||||||
|
end
|
||||||
|
dst
|
||||||
|
end
|
||||||
|
|
||||||
|
def define_installer_if_needed(bin)
|
||||||
|
exe = exefile("#{build_dir}/bin/#{bin}")
|
||||||
|
host? ? define_installer(exe) : exe
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename(name)
|
def filename(name)
|
||||||
@@ -326,7 +430,9 @@ EOS
|
|||||||
puts ">>> Bintest #{name} <<<"
|
puts ">>> Bintest #{name} <<<"
|
||||||
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
|
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
|
||||||
targets << filename(".") if File.directory? "./bintest"
|
targets << filename(".") if File.directory? "./bintest"
|
||||||
sh "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
|
mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile
|
||||||
|
env = {"BUILD_DIR" => @build_dir, "MRBCFILE" => mrbc}
|
||||||
|
sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_build_summary
|
def print_build_summary
|
||||||
@@ -359,6 +465,42 @@ EOS
|
|||||||
def libraries
|
def libraries
|
||||||
[libmruby_static]
|
[libmruby_static]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def host?
|
||||||
|
@name == "host"
|
||||||
|
end
|
||||||
|
|
||||||
|
def internal?
|
||||||
|
@internal
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
attr_writer :presym
|
||||||
|
|
||||||
|
def create_mrbc_build
|
||||||
|
exclusions = %i[@name @build_dir @gems @enable_test @enable_bintest @internal]
|
||||||
|
name = "#{@name}/mrbc"
|
||||||
|
MRuby.targets.delete(name)
|
||||||
|
build = self.class.new(name, internal: true){}
|
||||||
|
build.build_dir = "#{@build_dir}/mrbc"
|
||||||
|
instance_variables.each do |n|
|
||||||
|
next if exclusions.include?(n)
|
||||||
|
v = instance_variable_get(n)
|
||||||
|
v = case v
|
||||||
|
when nil, true, false, Numeric; v
|
||||||
|
when String, Command; v.clone
|
||||||
|
else Marshal.load(Marshal.dump(v)) # deep clone
|
||||||
|
end
|
||||||
|
build.instance_variable_set(n, v)
|
||||||
|
end
|
||||||
|
build.build_mrbc_exec
|
||||||
|
build.disable_libmruby
|
||||||
|
build.disable_presym
|
||||||
|
@mrbc_build = build
|
||||||
|
self.mrbcfile = build.mrbcfile
|
||||||
|
build
|
||||||
|
end
|
||||||
end # Build
|
end # Build
|
||||||
|
|
||||||
class CrossBuild < Build
|
class CrossBuild < Build
|
||||||
@@ -369,13 +511,21 @@ EOS
|
|||||||
attr_accessor :host_target, :build_target
|
attr_accessor :host_target, :build_target
|
||||||
|
|
||||||
def initialize(name, build_dir=nil, &block)
|
def initialize(name, build_dir=nil, &block)
|
||||||
@endian = nil
|
|
||||||
@test_runner = Command::CrossTestRunner.new(self)
|
@test_runner = Command::CrossTestRunner.new(self)
|
||||||
super
|
super
|
||||||
|
unless mrbcfile_external? || MRuby.targets['host']
|
||||||
|
# add minimal 'host'
|
||||||
|
MRuby::Build.new('host') do |conf|
|
||||||
|
conf.toolchain
|
||||||
|
conf.build_mrbc_exec
|
||||||
|
conf.disable_libmruby
|
||||||
|
conf.disable_presym
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def mrbcfile
|
def mrbcfile
|
||||||
MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/mrbc")
|
mrbcfile_external? ? super : MRuby::targets['host'].mrbcfile
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_test
|
def run_test
|
||||||
@@ -388,5 +538,9 @@ EOS
|
|||||||
@test_runner.run(mrbtest)
|
@test_runner.run(mrbtest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def create_mrbc_build; end
|
||||||
end # CrossBuild
|
end # CrossBuild
|
||||||
end # MRuby
|
end # MRuby
|
||||||
|
|||||||
+55
-37
@@ -32,28 +32,22 @@ module MRuby
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
NotFoundCommands = {}
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def _run(options, params={})
|
def _run(options, params={})
|
||||||
return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command
|
sh "#{build.filename(command)} #{options % params}"
|
||||||
begin
|
|
||||||
sh build.filename(command) + ' ' + ( options % params )
|
|
||||||
rescue RuntimeError
|
|
||||||
NotFoundCommands[@command] = true
|
|
||||||
_run options, params
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Command::Compiler < Command
|
class Command::Compiler < Command
|
||||||
attr_accessor :flags, :include_paths, :defines, :source_exts
|
attr_accessor :label, :flags, :include_paths, :defines, :source_exts
|
||||||
attr_accessor :compile_options, :option_define, :option_include_path, :out_ext
|
attr_accessor :compile_options, :option_define, :option_include_path, :out_ext
|
||||||
attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags
|
attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags
|
||||||
|
attr_writer :preprocess_options
|
||||||
|
|
||||||
def initialize(build, source_exts=[])
|
def initialize(build, source_exts=[], label: "CC")
|
||||||
super(build)
|
super(build)
|
||||||
@command = ENV['CC'] || 'cc'
|
@command = ENV['CC'] || 'cc'
|
||||||
|
@label = label
|
||||||
@flags = [ENV['CFLAGS'] || []]
|
@flags = [ENV['CFLAGS'] || []]
|
||||||
@source_exts = source_exts
|
@source_exts = source_exts
|
||||||
@include_paths = ["#{MRUBY_ROOT}/include"]
|
@include_paths = ["#{MRUBY_ROOT}/include"]
|
||||||
@@ -62,9 +56,15 @@ module MRuby
|
|||||||
@option_define = %q[-D"%s"]
|
@option_define = %q[-D"%s"]
|
||||||
@compile_options = %q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
@compile_options = %q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
||||||
@cxx_invalid_flags = []
|
@cxx_invalid_flags = []
|
||||||
|
@out_ext = build.exts.object
|
||||||
end
|
end
|
||||||
|
|
||||||
alias header_search_paths include_paths
|
alias header_search_paths include_paths
|
||||||
|
|
||||||
|
def preprocess_options
|
||||||
|
@preprocess_options ||= @compile_options.sub(/(?:\A|\s)\K-c(?=\s)/, "-E -P")
|
||||||
|
end
|
||||||
|
|
||||||
def search_header_path(name)
|
def search_header_path(name)
|
||||||
header_search_paths.find do |v|
|
header_search_paths.find do |v|
|
||||||
File.exist? build.filename("#{v}/#{name}").sub(/^"(.*)"$/, '\1')
|
File.exist? build.filename("#{v}/#{name}").sub(/^"(.*)"$/, '\1')
|
||||||
@@ -86,13 +86,20 @@ module MRuby
|
|||||||
|
|
||||||
def run(outfile, infile, _defines=[], _include_paths=[], _flags=[])
|
def run(outfile, infile, _defines=[], _include_paths=[], _flags=[])
|
||||||
mkdir_p File.dirname(outfile)
|
mkdir_p File.dirname(outfile)
|
||||||
_pp "CC", infile.relative_path, outfile.relative_path
|
flags = all_flags(_defines, _include_paths, _flags)
|
||||||
_run compile_options, { :flags => all_flags(_defines, _include_paths, _flags),
|
if object_ext?(outfile)
|
||||||
:infile => filename(infile), :outfile => filename(outfile) }
|
label = @label
|
||||||
|
opts = compile_options
|
||||||
|
else
|
||||||
|
label = "CPP"
|
||||||
|
opts = preprocess_options
|
||||||
|
flags << " -DMRB_PRESYM_SCANNING"
|
||||||
|
end
|
||||||
|
_pp label, infile.relative_path, outfile.relative_path
|
||||||
|
_run opts, flags: flags, infile: filename(infile), outfile: filename(outfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_rules(build_dir, source_dir='')
|
def define_rules(build_dir, source_dir='', out_ext=build.exts.object)
|
||||||
@out_ext = build.exts.object
|
|
||||||
gemrake = File.join(source_dir, "mrbgem.rake")
|
gemrake = File.join(source_dir, "mrbgem.rake")
|
||||||
rakedep = File.exist?(gemrake) ? [ gemrake ] : []
|
rakedep = File.exist?(gemrake) ? [ gemrake ] : []
|
||||||
|
|
||||||
@@ -133,18 +140,14 @@ module MRuby
|
|||||||
#
|
#
|
||||||
# ==== Without <tt>-MP</tt> compiler flag
|
# ==== Without <tt>-MP</tt> compiler flag
|
||||||
#
|
#
|
||||||
# /build/host/src/array.o: \
|
# /build/host/src/array.o: /src/array.c \
|
||||||
# /src/array.c \
|
# /include/mruby/common.h /include/mruby/value.h \
|
||||||
# /include/mruby/common.h \
|
|
||||||
# /include/mruby/value.h \
|
|
||||||
# /src/value_array.h
|
# /src/value_array.h
|
||||||
#
|
#
|
||||||
# ==== With <tt>-MP</tt> compiler flag
|
# ==== With <tt>-MP</tt> compiler flag
|
||||||
#
|
#
|
||||||
# /build/host/src/array.o: \
|
# /build/host/src/array.o: /src/array.c \
|
||||||
# /src/array.c \
|
# /include/mruby/common.h /include/mruby/value.h \
|
||||||
# /include/mruby/common.h \
|
|
||||||
# /include/mruby/value.h \
|
|
||||||
# /src/value_array.h
|
# /src/value_array.h
|
||||||
#
|
#
|
||||||
# /include/mruby/common.h:
|
# /include/mruby/common.h:
|
||||||
@@ -154,14 +157,25 @@ module MRuby
|
|||||||
# /src/value_array.h:
|
# /src/value_array.h:
|
||||||
#
|
#
|
||||||
def get_dependencies(file)
|
def get_dependencies(file)
|
||||||
file = file.ext('d') unless File.extname(file) == '.d'
|
dep_file = file.ext(".d")
|
||||||
deps = []
|
return [MRUBY_CONFIG] unless object_ext?(file) && File.exist?(dep_file)
|
||||||
if File.exist?(file)
|
|
||||||
File.foreach(file){|line| deps << $1 if /^ +(.*?)(?: *\\)?$/ =~ line}
|
deps = File.read(dep_file).gsub("\\\n ", "").split("\n").map do |dep_line|
|
||||||
deps.uniq!
|
# dep_line:
|
||||||
end
|
# - "/build/host/src/array.o: /src/array.c /include/mruby/common.h ..."
|
||||||
|
# - ""
|
||||||
|
# - "/include/mruby/common.h:"
|
||||||
|
dep_line.scan(/^\S+:\s+(.+)$/).flatten.map { |s| s.split(' ') }.flatten
|
||||||
|
# => ["/src/array.c", "/include/mruby/common.h" , ...]
|
||||||
|
# []
|
||||||
|
# []
|
||||||
|
end.flatten.uniq
|
||||||
deps << MRUBY_CONFIG
|
deps << MRUBY_CONFIG
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def object_ext?(path)
|
||||||
|
File.extname(path) == build.exts.object
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Command::Linker < Command
|
class Command::Linker < Command
|
||||||
@@ -191,6 +205,10 @@ module MRuby
|
|||||||
[libraries, _libraries].flatten.map{ |d| option_library % d }.join(' ')
|
[libraries, _libraries].flatten.map{ |d| option_library % d }.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run_attrs
|
||||||
|
[@libraries, @library_paths, @flags, @flags_before_libraries, @flags_after_libraries]
|
||||||
|
end
|
||||||
|
|
||||||
def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[], _flags_before_libraries=[], _flags_after_libraries=[])
|
def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[], _flags_before_libraries=[], _flags_after_libraries=[])
|
||||||
mkdir_p File.dirname(outfile)
|
mkdir_p File.dirname(outfile)
|
||||||
library_flags = [libraries, _libraries].flatten.map { |d| option_library % d }
|
library_flags = [libraries, _libraries].flatten.map { |d| option_library % d }
|
||||||
@@ -310,21 +328,21 @@ module MRuby
|
|||||||
@compile_options = "-B%{funcname} -o-"
|
@compile_options = "-B%{funcname} -o-"
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(out, infiles, funcname)
|
def run(out, infiles, funcname, cdump = true)
|
||||||
@command ||= @build.mrbcfile
|
@command ||= @build.mrbcfile
|
||||||
infiles = [infiles].flatten
|
infiles = [infiles].flatten
|
||||||
infiles.each do |f|
|
infiles.each_with_index do |f, i|
|
||||||
_pp "MRBC", f.relative_path, nil, :indent => 2
|
_pp i == 0 ? "MRBC" : "", f.relative_path, indent: 2
|
||||||
end
|
end
|
||||||
cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
|
cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
|
||||||
puts cmd if Rake.verbose
|
puts cmd if Rake.verbose
|
||||||
IO.popen(cmd, 'r+') do |io|
|
IO.popen(cmd, 'r+') do |io|
|
||||||
out.puts io.read
|
out.puts io.read
|
||||||
end
|
end
|
||||||
# if mrbc execution fail, drop the file
|
# if mrbc execution fail, drop the file
|
||||||
if $?.exitstatus != 0
|
unless $?.success?
|
||||||
File.delete(out.path)
|
rm_f out.path
|
||||||
exit(-1)
|
fail "Command failed with status (#{$?.exitstatus}): [#{cmd[0,42]}...]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,10 +15,13 @@ module MRuby
|
|||||||
def gem(gemdir, &block)
|
def gem(gemdir, &block)
|
||||||
if gemdir.is_a?(Hash)
|
if gemdir.is_a?(Hash)
|
||||||
gemdir = load_special_path_gem(gemdir)
|
gemdir = load_special_path_gem(gemdir)
|
||||||
elsif GemBox.path && gemdir.is_a?(String)
|
elsif GemBox.path
|
||||||
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
|
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
|
||||||
else
|
else
|
||||||
caller_dir = File.expand_path(File.dirname(caller(1,1)[0][/^(.*?):\d/,1]))
|
caller_dir = File.expand_path(File.dirname(caller(1,1)[0][/^(.*?):\d/,1]))
|
||||||
|
if caller_dir == "#{MRUBY_ROOT}/build_config"
|
||||||
|
caller_dir = MRUBY_ROOT
|
||||||
|
end
|
||||||
gemdir = File.expand_path(gemdir, caller_dir)
|
gemdir = File.expand_path(gemdir, caller_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,18 +31,17 @@ module MRuby
|
|||||||
Gem.current = nil
|
Gem.current = nil
|
||||||
load gemrake
|
load gemrake
|
||||||
return nil unless Gem.current
|
return nil unless Gem.current
|
||||||
|
current = Gem.current
|
||||||
|
|
||||||
Gem.current.dir = gemdir
|
current.dir = gemdir
|
||||||
Gem.current.build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current
|
current.build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current
|
||||||
Gem.current.build_config_initializer = block
|
current.build_config_initializer = block
|
||||||
gems << Gem.current
|
gems << current
|
||||||
|
|
||||||
cxx_srcs = ['src', 'test', 'tools'].map do |subdir|
|
cxx_srcs = Dir.glob("#{current.dir}/{src,test,tools}/*.{cpp,cxx,cc}")
|
||||||
Dir.glob("#{Gem.current.dir}/#{subdir}/*.{cpp,cxx,cc}")
|
|
||||||
end.flatten
|
|
||||||
enable_cxx_exception unless cxx_srcs.empty?
|
enable_cxx_exception unless cxx_srcs.empty?
|
||||||
|
|
||||||
Gem.current
|
current
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_special_path_gem(params)
|
def load_special_path_gem(params)
|
||||||
@@ -98,7 +100,7 @@ module MRuby
|
|||||||
options = [params[:options]] || []
|
options = [params[:options]] || []
|
||||||
options << "--recursive"
|
options << "--recursive"
|
||||||
options << "--branch \"#{branch}\""
|
options << "--branch \"#{branch}\""
|
||||||
options << "--depth 1" unless params[:checksum_hash]
|
options << "--depth 1" unless params[:checksum_hash] || lock
|
||||||
mkdir_p "#{gem_clone_dir}"
|
mkdir_p "#{gem_clone_dir}"
|
||||||
git.run_clone gemdir, url, options
|
git.run_clone gemdir, url, options
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,17 @@ class String
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def _pp(cmd, src, tgt=nil, options={})
|
def install_D(src, dst)
|
||||||
return if Rake.verbose
|
_pp "INSTALL", src.relative_path, dst.relative_path
|
||||||
|
rm_f dst
|
||||||
|
mkdir_p File.dirname(dst)
|
||||||
|
cp src, dst
|
||||||
|
end
|
||||||
|
|
||||||
|
def _pp(cmd, src, tgt=nil, indent: nil)
|
||||||
|
return if Rake.application.options.silent
|
||||||
|
|
||||||
width = 5
|
width = 5
|
||||||
template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s"
|
template = indent ? "%#{width * indent}s %s %s" : "%-#{width}s %s %s"
|
||||||
puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]
|
puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]
|
||||||
end
|
end
|
||||||
+75
-32
@@ -7,7 +7,6 @@ module MRuby
|
|||||||
class << self
|
class << self
|
||||||
attr_accessor :current
|
attr_accessor :current
|
||||||
end
|
end
|
||||||
LinkerConfig = Struct.new(:libraries, :library_paths, :flags, :flags_before_libraries, :flags_after_libraries)
|
|
||||||
|
|
||||||
class Specification
|
class Specification
|
||||||
include Rake::DSL
|
include Rake::DSL
|
||||||
@@ -17,7 +16,6 @@ module MRuby
|
|||||||
attr_accessor :name, :dir, :build
|
attr_accessor :name, :dir, :build
|
||||||
alias mruby build
|
alias mruby build
|
||||||
attr_accessor :build_config_initializer
|
attr_accessor :build_config_initializer
|
||||||
attr_accessor :mrblib_dir, :objs_dir
|
|
||||||
|
|
||||||
attr_accessor :version
|
attr_accessor :version
|
||||||
attr_accessor :description, :summary
|
attr_accessor :description, :summary
|
||||||
@@ -27,8 +25,8 @@ module MRuby
|
|||||||
alias :author= :authors=
|
alias :author= :authors=
|
||||||
|
|
||||||
attr_accessor :rbfiles, :objs
|
attr_accessor :rbfiles, :objs
|
||||||
attr_accessor :test_objs, :test_rbfiles, :test_args
|
attr_writer :test_objs, :test_rbfiles
|
||||||
attr_accessor :test_preload
|
attr_accessor :test_args, :test_preload
|
||||||
|
|
||||||
attr_accessor :bins
|
attr_accessor :bins
|
||||||
|
|
||||||
@@ -45,37 +43,30 @@ module MRuby
|
|||||||
@name = name
|
@name = name
|
||||||
@initializer = block
|
@initializer = block
|
||||||
@version = "0.0.0"
|
@version = "0.0.0"
|
||||||
@mrblib_dir = "mrblib"
|
@dependencies = []
|
||||||
@objs_dir = "src"
|
@conflicts = []
|
||||||
MRuby::Gem.current = self
|
MRuby::Gem.current = self
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
return if defined?(@linker) # return if already set up
|
return if defined?(@bins) # return if already set up
|
||||||
|
|
||||||
MRuby::Gem.current = self
|
MRuby::Gem.current = self
|
||||||
MRuby::Build::COMMANDS.each do |command|
|
MRuby::Build::COMMANDS.each do |command|
|
||||||
instance_variable_set("@#{command}", @build.send(command).clone)
|
instance_variable_set("@#{command}", @build.send(command).clone)
|
||||||
end
|
end
|
||||||
@linker = LinkerConfig.new([], [], [], [], [])
|
@linker.run_attrs.each(&:clear)
|
||||||
|
|
||||||
@rbfiles = Dir.glob("#{@dir}/#{@mrblib_dir}/**/*.rb").sort
|
@rbfiles = Dir.glob("#{@dir}/mrblib/**/*.rb").sort
|
||||||
@objs = Dir.glob("#{@dir}/#{@objs_dir}/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
|
@objs = srcs_to_objs("src")
|
||||||
objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
|
|
||||||
end
|
|
||||||
|
|
||||||
@test_rbfiles = Dir.glob("#{dir}/test/**/*.rb").sort
|
|
||||||
@test_objs = Dir.glob("#{dir}/test/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
|
|
||||||
objfile(f.relative_path_from(dir).to_s.pathmap("#{build_dir}/%X"))
|
|
||||||
end
|
|
||||||
@custom_test_init = !@test_objs.empty?
|
|
||||||
@test_preload = nil # 'test/assert.rb'
|
@test_preload = nil # 'test/assert.rb'
|
||||||
@test_args = {}
|
@test_args = {}
|
||||||
|
|
||||||
@bins = []
|
@bins = []
|
||||||
|
@cdump = true
|
||||||
|
|
||||||
@requirements = []
|
@requirements = []
|
||||||
@dependencies, @conflicts = [], []
|
|
||||||
@export_include_paths = []
|
@export_include_paths = []
|
||||||
@export_include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
|
@export_include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
|
||||||
|
|
||||||
@@ -97,10 +88,11 @@ module MRuby
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup_compilers
|
def setup_compilers
|
||||||
compilers.each do |compiler|
|
(core? ? [@cc, *(@cxx if build.cxx_exception_enabled?)] : compilers).each do |compiler|
|
||||||
compiler.define_rules build_dir, "#{dir}"
|
compiler.define_rules build_dir, @dir, @build.exts.presym_preprocessed if build.presym_enabled?
|
||||||
|
compiler.define_rules build_dir, @dir, @build.exts.object
|
||||||
compiler.defines << %Q[MRBGEM_#{funcname.upcase}_VERSION=#{version}]
|
compiler.defines << %Q[MRBGEM_#{funcname.upcase}_VERSION=#{version}]
|
||||||
compiler.include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
|
compiler.include_paths << "#{@dir}/include" if File.directory? "#{@dir}/include"
|
||||||
end
|
end
|
||||||
|
|
||||||
define_gem_init_builder if @generate_functions
|
define_gem_init_builder if @generate_functions
|
||||||
@@ -115,6 +107,18 @@ module MRuby
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disable_cdump
|
||||||
|
@cdump = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def cdump?
|
||||||
|
build.presym_enabled? && @cdump
|
||||||
|
end
|
||||||
|
|
||||||
|
def core?
|
||||||
|
@dir.start_with?("#{MRUBY_ROOT}/mrbgems/")
|
||||||
|
end
|
||||||
|
|
||||||
def add_dependency(name, *requirements)
|
def add_dependency(name, *requirements)
|
||||||
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
|
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
|
||||||
requirements = ['>= 0.0.0'] if requirements.empty?
|
requirements = ['>= 0.0.0'] if requirements.empty?
|
||||||
@@ -138,6 +142,14 @@ module MRuby
|
|||||||
"#{build_dir}/gem_test.c"
|
"#{build_dir}/gem_test.c"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_objs
|
||||||
|
@test_objs ||= srcs_to_objs("test")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_rbfiles
|
||||||
|
@test_rbfiles ||= Dir["#{@dir}/test/**/*.rb"].sort!
|
||||||
|
end
|
||||||
|
|
||||||
def search_package(name, version_query=nil)
|
def search_package(name, version_query=nil)
|
||||||
package_query = name
|
package_query = name
|
||||||
package_query += " #{version_query}" if version_query
|
package_query += " #{version_query}" if version_query
|
||||||
@@ -163,8 +175,14 @@ module MRuby
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def srcs_to_objs(src_dir_from_gem_dir)
|
||||||
|
exts = compilers.flat_map{|c| c.source_exts} * ","
|
||||||
|
Dir["#{@dir}/#{src_dir_from_gem_dir}/*{#{exts}}"].map do |f|
|
||||||
|
objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def define_gem_init_builder
|
def define_gem_init_builder
|
||||||
file objfile("#{build_dir}/gem_init") => [ "#{build_dir}/gem_init.c", File.join(dir, "mrbgem.rake") ]
|
|
||||||
file "#{build_dir}/gem_init.c" => [build.mrbcfile, __FILE__] + [rbfiles].flatten do |t|
|
file "#{build_dir}/gem_init.c" => [build.mrbcfile, __FILE__] + [rbfiles].flatten do |t|
|
||||||
mkdir_p build_dir
|
mkdir_p build_dir
|
||||||
generate_gem_init("#{build_dir}/gem_init.c")
|
generate_gem_init("#{build_dir}/gem_init.c")
|
||||||
@@ -172,22 +190,37 @@ module MRuby
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate_gem_init(fname)
|
def generate_gem_init(fname)
|
||||||
|
_pp "GEN", fname.relative_path
|
||||||
open(fname, 'w') do |f|
|
open(fname, 'w') do |f|
|
||||||
print_gem_init_header f
|
print_gem_init_header f
|
||||||
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}" unless rbfiles.empty?
|
unless rbfiles.empty?
|
||||||
|
if cdump?
|
||||||
|
build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc"
|
||||||
|
else
|
||||||
|
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", false
|
||||||
|
end
|
||||||
|
end
|
||||||
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]
|
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]
|
||||||
f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);]
|
f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);]
|
||||||
f.puts %Q[]
|
f.puts %Q[]
|
||||||
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {]
|
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {]
|
||||||
f.puts %Q[ int ai = mrb_gc_arena_save(mrb);]
|
f.puts %Q[ int ai = mrb_gc_arena_save(mrb);]
|
||||||
|
f.puts %Q[ gem_mrblib_#{funcname}_proc_init_syms(mrb);] if !rbfiles.empty? && cdump?
|
||||||
f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
|
f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
|
||||||
unless rbfiles.empty?
|
unless rbfiles.empty?
|
||||||
f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});]
|
if cdump?
|
||||||
|
f.puts %Q[ mrb_load_proc(mrb, gem_mrblib_#{funcname}_proc);]
|
||||||
|
else
|
||||||
|
f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});]
|
||||||
|
end
|
||||||
f.puts %Q[ if (mrb->exc) {]
|
f.puts %Q[ if (mrb->exc) {]
|
||||||
f.puts %Q[ mrb_print_error(mrb);]
|
f.puts %Q[ mrb_print_error(mrb);]
|
||||||
f.puts %Q[ mrb_close(mrb);]
|
f.puts %Q[ mrb_close(mrb);]
|
||||||
f.puts %Q[ exit(EXIT_FAILURE);]
|
f.puts %Q[ exit(EXIT_FAILURE);]
|
||||||
f.puts %Q[ }]
|
f.puts %Q[ }]
|
||||||
|
f.puts %Q[ struct REnv *e = mrb_vm_ci_env(mrb->c->cibase);]
|
||||||
|
f.puts %Q[ mrb_vm_ci_env_set(mrb->c->cibase, NULL);]
|
||||||
|
f.puts %Q[ mrb_env_unshare(mrb, e);]
|
||||||
end
|
end
|
||||||
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
|
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
|
||||||
f.puts %Q[}]
|
f.puts %Q[}]
|
||||||
@@ -211,9 +244,15 @@ module MRuby
|
|||||||
|
|
||||||
def print_gem_init_header(f)
|
def print_gem_init_header(f)
|
||||||
print_gem_comment(f)
|
print_gem_comment(f)
|
||||||
f.puts %Q[#include <stdlib.h>] unless rbfiles.empty?
|
if rbfiles.empty?
|
||||||
f.puts %Q[#include <mruby.h>]
|
f.puts %Q[#include <mruby.h>]
|
||||||
f.puts %Q[#include <mruby/irep.h>] unless rbfiles.empty?
|
else
|
||||||
|
f.puts %Q[#include <stdlib.h>]
|
||||||
|
unless build.presym_enabled?
|
||||||
|
f.puts %Q[#include <mruby.h>]
|
||||||
|
f.puts %Q[#include <mruby/proc.h>]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_gem_test_header(f)
|
def print_gem_test_header(f)
|
||||||
@@ -226,12 +265,8 @@ module MRuby
|
|||||||
f.puts %Q[#include <mruby/hash.h>] unless test_args.empty?
|
f.puts %Q[#include <mruby/hash.h>] unless test_args.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dependencies
|
|
||||||
[@name]
|
|
||||||
end
|
|
||||||
|
|
||||||
def custom_test_init?
|
def custom_test_init?
|
||||||
@custom_test_init
|
!test_objs.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def version_ok?(req_versions)
|
def version_ok?(req_versions)
|
||||||
@@ -323,6 +358,10 @@ module MRuby
|
|||||||
@ary.each(&b)
|
@ary.each(&b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def [](name)
|
||||||
|
@ary.detect {|g| g.name == name}
|
||||||
|
end
|
||||||
|
|
||||||
def <<(gem)
|
def <<(gem)
|
||||||
unless @ary.detect {|g| g.dir == gem.dir }
|
unless @ary.detect {|g| g.dir == gem.dir }
|
||||||
@ary << gem
|
@ary << gem
|
||||||
@@ -456,6 +495,10 @@ module MRuby
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def linker_attrs
|
||||||
|
map{|g| g.linker.run_attrs}.transpose
|
||||||
|
end
|
||||||
end # List
|
end # List
|
||||||
end # Gem
|
end # Gem
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ module MRuby
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write
|
def write
|
||||||
locks = {"mruby_version" => mruby}
|
locks = {"mruby" => mruby}
|
||||||
locks["builds"] = @builds if @builds
|
locks["builds"] = @builds if @builds
|
||||||
File.write(@filename, YAML.dump(locks))
|
File.write(@filename, YAML.dump(locks))
|
||||||
end
|
end
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user