script_core 0.2.7 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +2 -2
  4. data/ext/enterprise_script_service/Rakefile +1 -1
  5. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +117 -74
  6. data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +41 -37
  7. data/ext/enterprise_script_service/mruby/.github/workflows/lint.yml +23 -0
  8. data/ext/enterprise_script_service/mruby/.github/workflows/oss-fuzz.yml +27 -0
  9. data/ext/enterprise_script_service/mruby/.github/workflows/spell-checker.yml +17 -0
  10. data/ext/enterprise_script_service/mruby/.gitlab-ci.yml +3 -3
  11. data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
  12. data/ext/enterprise_script_service/mruby/.travis.yml +2 -2
  13. data/ext/enterprise_script_service/mruby/.yamllint +8 -0
  14. data/ext/enterprise_script_service/mruby/AUTHORS +3 -0
  15. data/ext/enterprise_script_service/mruby/CODEOWNERS +1 -0
  16. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +6 -13
  17. data/ext/enterprise_script_service/mruby/Doxyfile +4 -4
  18. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  19. data/ext/enterprise_script_service/mruby/Makefile +1 -1
  20. data/ext/enterprise_script_service/mruby/README.md +4 -14
  21. data/ext/enterprise_script_service/mruby/Rakefile +18 -108
  22. data/ext/enterprise_script_service/mruby/TODO.md +17 -0
  23. data/ext/enterprise_script_service/mruby/appveyor.yml +31 -25
  24. data/ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb +1 -1
  25. data/ext/enterprise_script_service/mruby/build_config.rb +9 -152
  26. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_ArduinoDue.rb → build_config/ArduinoDue.rb} +2 -19
  27. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +2 -2
  28. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +1 -18
  29. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +2 -19
  30. data/ext/enterprise_script_service/mruby/build_config/android_arm64-v8a.rb +11 -0
  31. data/ext/enterprise_script_service/mruby/build_config/android_armeabi.rb +11 -0
  32. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_android_armeabi_v7a_neon_hard.rb → build_config/android_armeabi_v7a_neon_hard.rb} +0 -15
  33. data/ext/enterprise_script_service/mruby/build_config/bench.rb +11 -0
  34. data/ext/enterprise_script_service/mruby/build_config/boxing.rb +21 -0
  35. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_chipKITMax32.rb → build_config/chipKITMax32.rb} +2 -19
  36. data/ext/enterprise_script_service/mruby/{travis_config.rb → build_config/ci/gcc-clang.rb} +10 -10
  37. data/ext/enterprise_script_service/mruby/build_config/ci/msvc.rb +20 -0
  38. data/ext/enterprise_script_service/mruby/build_config/clang-asan.rb +11 -0
  39. data/ext/enterprise_script_service/mruby/build_config/cross-32bit.rb +14 -0
  40. data/ext/enterprise_script_service/mruby/build_config/default.rb +80 -0
  41. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_dreamcast_shelf.rb → build_config/dreamcast_shelf.rb} +5 -19
  42. data/ext/enterprise_script_service/mruby/build_config/gameboyadvance.rb +73 -0
  43. data/ext/enterprise_script_service/mruby/build_config/host-cxx.rb +12 -0
  44. data/ext/enterprise_script_service/mruby/build_config/host-debug.rb +20 -0
  45. data/ext/enterprise_script_service/mruby/build_config/host-gprof.rb +14 -0
  46. data/ext/enterprise_script_service/mruby/build_config/host-m32.rb +15 -0
  47. data/ext/enterprise_script_service/mruby/build_config/host-shared.rb +36 -0
  48. data/ext/enterprise_script_service/mruby/build_config/mrbc.rb +11 -0
  49. data/ext/enterprise_script_service/mruby/build_config/no-float.rb +17 -0
  50. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +138 -49
  51. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +5 -4
  52. data/ext/enterprise_script_service/mruby/doc/guides/gc-arena-howto.md +1 -1
  53. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +49 -22
  54. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +31 -14
  55. data/ext/enterprise_script_service/mruby/doc/guides/symbol.md +83 -0
  56. data/ext/enterprise_script_service/mruby/doc/limitations.md +35 -36
  57. data/ext/enterprise_script_service/mruby/doc/mruby3.md +163 -0
  58. data/ext/enterprise_script_service/mruby/doc/opcode.md +93 -107
  59. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +1 -1
  60. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +5 -1
  61. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_extension_example/src/example.c +5 -1
  62. data/ext/enterprise_script_service/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +1 -1
  63. data/ext/enterprise_script_service/mruby/include/mrbconf.h +81 -62
  64. data/ext/enterprise_script_service/mruby/include/mruby.h +137 -96
  65. data/ext/enterprise_script_service/mruby/include/mruby/array.h +23 -6
  66. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +73 -48
  67. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
  68. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +79 -48
  69. data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
  70. data/ext/enterprise_script_service/mruby/include/mruby/common.h +4 -1
  71. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +13 -7
  72. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  73. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +17 -35
  74. data/ext/enterprise_script_service/mruby/include/mruby/endian.h +44 -0
  75. data/ext/enterprise_script_service/mruby/include/mruby/error.h +39 -5
  76. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +1 -0
  77. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +33 -13
  78. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +64 -14
  79. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +6 -14
  80. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +36 -63
  81. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
  82. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +27 -23
  83. data/ext/enterprise_script_service/mruby/include/mruby/presym.h +40 -0
  84. data/ext/enterprise_script_service/mruby/include/mruby/presym/disable.h +70 -0
  85. data/ext/enterprise_script_service/mruby/include/mruby/presym/enable.h +37 -0
  86. data/ext/enterprise_script_service/mruby/include/mruby/presym/scanning.h +73 -0
  87. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +80 -13
  88. data/ext/enterprise_script_service/mruby/include/mruby/string.h +10 -15
  89. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
  90. data/ext/enterprise_script_service/mruby/include/mruby/value.h +29 -19
  91. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
  92. data/ext/enterprise_script_service/mruby/include/mruby/version.h +26 -7
  93. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -44
  94. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +55 -37
  95. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +12 -10
  96. data/ext/enterprise_script_service/mruby/lib/{mruby-core-ext.rb → mruby/core_ext.rb} +10 -3
  97. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +75 -32
  98. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +1 -1
  99. data/ext/enterprise_script_service/mruby/lib/mruby/presym.rb +132 -0
  100. data/ext/enterprise_script_service/mruby/mrbgems/default-no-fpu.gembox +3 -0
  101. data/ext/enterprise_script_service/mruby/mrbgems/default-no-stdio.gembox +4 -0
  102. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +9 -88
  103. data/ext/enterprise_script_service/mruby/mrbgems/full-core.gembox +1 -4
  104. data/ext/enterprise_script_service/mruby/mrbgems/math.gembox +10 -0
  105. data/ext/enterprise_script_service/mruby/mrbgems/metaprog.gembox +15 -0
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +1 -1
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -4
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +28 -19
  109. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mruby-config +18 -8
  110. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +3 -6
  111. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +10 -10
  112. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +14 -9
  113. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +3 -2
  114. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +4 -3
  115. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +2 -6
  116. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -4
  117. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +23 -5
  118. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +11 -2
  119. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +41 -34
  120. data/ext/enterprise_script_service/mruby/mrbgems/{mruby-compiler → mruby-bin-mrbc}/bintest/mrbc.rb +0 -0
  121. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake +3 -4
  122. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +19 -9
  123. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +25 -4
  124. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -1
  125. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +22 -6
  126. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +1 -1
  127. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +2 -2
  128. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrbgem.rake +5 -0
  129. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrblib/catch.rb +27 -0
  130. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +2 -1
  131. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +430 -399
  132. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +5 -0
  133. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +49 -44
  134. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +559 -217
  135. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +4774 -4193
  136. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +18 -19
  137. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +8 -7
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +4 -4
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +1 -0
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +2 -2
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/mrbgem.rake +2 -2
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +17 -25
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +18 -13
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +30 -2
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +7 -0
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +2 -2
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +18 -16
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +2 -2
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +2 -2
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +55 -52
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +4 -2
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +99 -87
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +2 -0
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +2 -3
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +1 -1
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +7 -6
  159. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +13 -12
  160. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/test/math.rb +5 -4
  161. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +43 -58
  162. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +4 -4
  163. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/README.md +4 -3
  164. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +77 -74
  165. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +4 -4
  166. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +14 -13
  167. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +5 -4
  168. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -12
  169. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/mrbgem.rake +10 -0
  170. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/src/memsize.c +231 -0
  171. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/test/memsize.rb +63 -0
  172. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/README.md +15 -18
  173. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +38 -88
  174. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +1 -30
  175. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +62 -26
  176. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +32 -19
  177. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.c +1 -1
  178. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +98 -43
  179. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +2 -2
  180. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +39 -6
  181. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +20 -40
  182. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +27 -3
  183. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +11 -17
  184. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +216 -38
  185. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +6 -6
  186. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/README.md +6 -4
  187. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +4 -4
  188. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
  189. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
  190. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +102 -71
  191. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +4 -2
  192. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +23 -1
  193. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +13 -9
  194. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +1 -1
  195. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +18 -25
  196. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +6 -5
  197. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  198. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/README.md +0 -1
  199. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +5 -5
  200. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +16 -44
  201. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +4 -4
  202. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +27 -27
  203. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-ext.gembox +18 -0
  204. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-io.gembox +12 -0
  205. data/ext/enterprise_script_service/mruby/mrbgems/stdlib.gembox +54 -0
  206. data/ext/enterprise_script_service/mruby/mrblib/10error.rb +4 -0
  207. data/ext/enterprise_script_service/mruby/mrblib/array.rb +17 -9
  208. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +1 -1
  209. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +0 -20
  210. data/ext/enterprise_script_service/mruby/mrblib/init_mrblib.c +0 -11
  211. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +36 -11
  212. data/ext/enterprise_script_service/mruby/mrblib/range.rb +25 -3
  213. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +2 -2
  214. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +1 -1
  215. data/ext/enterprise_script_service/mruby/src/array.c +43 -80
  216. data/ext/enterprise_script_service/mruby/src/backtrace.c +16 -17
  217. data/ext/enterprise_script_service/mruby/src/class.c +774 -182
  218. data/ext/enterprise_script_service/mruby/src/codedump.c +223 -198
  219. data/ext/enterprise_script_service/mruby/src/debug.c +6 -6
  220. data/ext/enterprise_script_service/mruby/src/dump.c +466 -141
  221. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  222. data/ext/enterprise_script_service/mruby/src/error.c +36 -13
  223. data/ext/enterprise_script_service/mruby/src/etc.c +43 -34
  224. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +5 -6
  225. data/ext/enterprise_script_service/mruby/src/gc.c +73 -71
  226. data/ext/enterprise_script_service/mruby/src/hash.c +1050 -707
  227. data/ext/enterprise_script_service/mruby/src/kernel.c +75 -220
  228. data/ext/enterprise_script_service/mruby/src/load.c +196 -166
  229. data/ext/enterprise_script_service/mruby/src/numeric.c +352 -314
  230. data/ext/enterprise_script_service/mruby/src/object.c +97 -90
  231. data/ext/enterprise_script_service/mruby/src/print.c +4 -3
  232. data/ext/enterprise_script_service/mruby/src/proc.c +48 -56
  233. data/ext/enterprise_script_service/mruby/src/range.c +45 -21
  234. data/ext/enterprise_script_service/mruby/src/state.c +25 -32
  235. data/ext/enterprise_script_service/mruby/src/string.c +59 -101
  236. data/ext/enterprise_script_service/mruby/src/symbol.c +121 -56
  237. data/ext/enterprise_script_service/mruby/src/value_array.h +1 -0
  238. data/ext/enterprise_script_service/mruby/src/variable.c +158 -158
  239. data/ext/enterprise_script_service/mruby/src/vm.c +617 -602
  240. data/ext/enterprise_script_service/mruby/tasks/benchmark.rake +6 -6
  241. data/ext/enterprise_script_service/mruby/tasks/bin.rake +23 -0
  242. data/ext/enterprise_script_service/mruby/tasks/core.rake +12 -0
  243. data/ext/enterprise_script_service/mruby/tasks/doc.rake +50 -38
  244. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +83 -77
  245. data/ext/enterprise_script_service/mruby/tasks/libmruby.rake +10 -1
  246. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +13 -1
  247. data/ext/enterprise_script_service/mruby/tasks/mrblib.rake +40 -0
  248. data/ext/enterprise_script_service/mruby/tasks/presym.rake +44 -0
  249. data/ext/enterprise_script_service/mruby/tasks/test.rake +68 -0
  250. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +6 -5
  251. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +10 -14
  252. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +17 -21
  253. data/ext/enterprise_script_service/mruby/test/bintest.rb +5 -5
  254. data/ext/enterprise_script_service/mruby/test/t/argumenterror.rb +16 -0
  255. data/ext/enterprise_script_service/mruby/test/t/array.rb +7 -3
  256. data/ext/enterprise_script_service/mruby/test/t/bs_literal.rb +1 -1
  257. data/ext/enterprise_script_service/mruby/test/t/float.rb +18 -8
  258. data/ext/enterprise_script_service/mruby/test/t/hash.rb +903 -281
  259. data/ext/enterprise_script_service/mruby/test/t/integer.rb +10 -38
  260. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +1 -1
  261. data/ext/enterprise_script_service/mruby/test/t/literals.rb +50 -0
  262. data/ext/enterprise_script_service/mruby/test/t/module.rb +2 -2
  263. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +1 -1
  264. data/ext/enterprise_script_service/mruby/test/t/range.rb +83 -1
  265. data/ext/enterprise_script_service/mruby/test/t/string.rb +4 -0
  266. data/ext/enterprise_script_service/mruby/test/t/superclass.rb +10 -10
  267. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +24 -0
  268. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +3 -3
  269. data/ext/enterprise_script_service/mruby_config.rb +2 -5
  270. data/ext/enterprise_script_service/mruby_engine.cpp +1 -1
  271. data/lib/script_core/version.rb +1 -1
  272. data/spec/script_core_spec.rb +13 -0
  273. metadata +61 -23
  274. data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +0 -24
  275. data/ext/enterprise_script_service/mruby/TODO +0 -8
  276. data/ext/enterprise_script_service/mruby/appveyor_config.rb +0 -46
  277. data/ext/enterprise_script_service/mruby/benchmark/build_config_boxing.rb +0 -28
  278. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_arm64-v8a.rb +0 -26
  279. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_armeabi.rb +0 -26
  280. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +0 -30
  281. data/ext/enterprise_script_service/mruby/mrblib/mrblib.rake +0 -18
  282. data/ext/enterprise_script_service/mruby/src/crc.c +0 -39
  283. data/ext/enterprise_script_service/mruby/src/mruby_core.rake +0 -19
@@ -7,13 +7,15 @@
7
7
  #ifndef MRB_THROW_H
8
8
  #define MRB_THROW_H
9
9
 
10
- #if defined(MRB_ENABLE_CXX_ABI)
10
+ #if defined(MRB_USE_CXX_ABI)
11
11
  # if !defined(__cplusplus)
12
12
  # error Trying to use C++ exception handling in C code
13
13
  # endif
14
14
  #endif
15
15
 
16
- #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
16
+ #if defined(MRB_USE_CXX_EXCEPTION)
17
+
18
+ # if defined(__cplusplus)
17
19
 
18
20
  #define MRB_TRY(buf) try {
19
21
  #define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
@@ -22,6 +24,10 @@
22
24
  #define MRB_THROW(buf) throw((buf)->impl)
23
25
  typedef mrb_int mrb_jmpbuf_impl;
24
26
 
27
+ # else
28
+ # error "need to be compiled with C++ compiler"
29
+ # endif /* __cplusplus */
30
+
25
31
  #else
26
32
 
27
33
  #include <setjmp.h>
@@ -29,6 +35,9 @@ typedef mrb_int mrb_jmpbuf_impl;
29
35
  #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
30
36
  #define MRB_SETJMP _setjmp
31
37
  #define MRB_LONGJMP _longjmp
38
+ #elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
39
+ #define MRB_SETJMP __builtin_setjmp
40
+ #define MRB_LONGJMP __builtin_longjmp
32
41
  #else
33
42
  #define MRB_SETJMP setjmp
34
43
  #define MRB_LONGJMP longjmp
@@ -46,9 +55,11 @@ typedef mrb_int mrb_jmpbuf_impl;
46
55
  struct mrb_jmpbuf {
47
56
  mrb_jmpbuf_impl impl;
48
57
 
49
- #if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
58
+ #if defined(MRB_USE_CXX_EXCEPTION)
50
59
  static mrb_int jmpbuf_id;
60
+ # if defined(__cplusplus)
51
61
  mrb_jmpbuf() : impl(jmpbuf_id++) {}
62
+ # endif
52
63
  #endif
53
64
  };
54
65
 
@@ -53,17 +53,19 @@ struct mrb_state;
53
53
 
54
54
  #if defined(MRB_INT64)
55
55
  typedef int64_t mrb_int;
56
+ typedef uint64_t mrb_uint;
56
57
  # define MRB_INT_BIT 64
57
- # define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
58
- # define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
58
+ # define MRB_INT_MIN INT64_MIN
59
+ # define MRB_INT_MAX INT64_MAX
59
60
  # define MRB_PRIo PRIo64
60
61
  # define MRB_PRId PRId64
61
62
  # define MRB_PRIx PRIx64
62
63
  #else
63
64
  typedef int32_t mrb_int;
65
+ typedef uint32_t mrb_uint;
64
66
  # define MRB_INT_BIT 32
65
- # define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
66
- # define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
67
+ # define MRB_INT_MIN INT32_MIN
68
+ # define MRB_INT_MAX INT32_MAX
67
69
  # define MRB_PRIo PRIo32
68
70
  # define MRB_PRId PRId32
69
71
  # define MRB_PRIx PRIx32
@@ -75,9 +77,9 @@ struct mrb_state;
75
77
  # define MRB_ENDIAN_LOHI(a,b) b a
76
78
  #endif
77
79
 
78
- #ifndef MRB_WITHOUT_FLOAT
80
+ #ifndef MRB_NO_FLOAT
79
81
  MRB_API double mrb_float_read(const char*, char**);
80
- #ifdef MRB_USE_FLOAT
82
+ #ifdef MRB_USE_FLOAT32
81
83
  typedef float mrb_float;
82
84
  #else
83
85
  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
90
92
  MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
91
93
  # define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
92
94
  # define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
93
- # if _MSC_VER < 1800 && !defined MRB_WITHOUT_FLOAT
95
+ # if _MSC_VER < 1800 && !defined MRB_NO_FLOAT
94
96
  # include <float.h>
95
97
  # define isfinite(n) _finite(n)
96
98
  # define isnan _isnan
@@ -106,7 +108,7 @@ enum mrb_vtype {
106
108
  MRB_TT_FALSE = 0,
107
109
  MRB_TT_TRUE,
108
110
  MRB_TT_FLOAT,
109
- MRB_TT_FIXNUM,
111
+ MRB_TT_INTEGER,
110
112
  MRB_TT_SYMBOL,
111
113
  MRB_TT_UNDEF,
112
114
  MRB_TT_CPTR,
@@ -130,6 +132,9 @@ enum mrb_vtype {
130
132
  MRB_TT_MAXDEFINE
131
133
  };
132
134
 
135
+ /* for compatibility */
136
+ #define MRB_TT_FIXNUM MRB_TT_INTEGER
137
+
133
138
  #include <mruby/object.h>
134
139
 
135
140
  #ifdef MRB_DOCUMENTATION_BLOCK
@@ -163,12 +168,9 @@ struct RCptr {
163
168
  #include "boxing_no.h"
164
169
  #endif
165
170
 
166
- #define MRB_SYMBOL_BIT (sizeof(mrb_sym) * CHAR_BIT - MRB_SYMBOL_SHIFT)
167
- #define MRB_SYMBOL_MAX (UINT32_MAX >> MRB_SYMBOL_SHIFT)
168
-
169
171
  #if INTPTR_MAX < MRB_INT_MAX
170
172
  typedef intptr_t mrb_ssize;
171
- # define MRB_SSIZE_MAX (INTPTR_MAX>>MRB_FIXNUM_SHIFT)
173
+ # define MRB_SSIZE_MAX INTPTR_MAX
172
174
  #else
173
175
  typedef mrb_int mrb_ssize;
174
176
  # define MRB_SSIZE_MAX MRB_INT_MAX
@@ -177,8 +179,11 @@ struct RCptr {
177
179
  #ifndef mrb_immediate_p
178
180
  #define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
179
181
  #endif
182
+ #ifndef mrb_integer_p
183
+ #define mrb_integer_p(o) (mrb_type(o) == MRB_TT_INTEGER)
184
+ #endif
180
185
  #ifndef mrb_fixnum_p
181
- #define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
186
+ #define mrb_fixnum_p(o) mrb_integer_p(o)
182
187
  #endif
183
188
  #ifndef mrb_symbol_p
184
189
  #define mrb_symbol_p(o) (mrb_type(o) == MRB_TT_SYMBOL)
@@ -195,7 +200,7 @@ struct RCptr {
195
200
  #ifndef mrb_true_p
196
201
  #define mrb_true_p(o) (mrb_type(o) == MRB_TT_TRUE)
197
202
  #endif
198
- #ifndef MRB_WITHOUT_FLOAT
203
+ #ifndef MRB_NO_FLOAT
199
204
  #ifndef mrb_float_p
200
205
  #define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
201
206
  #endif
@@ -264,7 +269,7 @@ struct RCptr {
264
269
  *
265
270
  * Takes a float and boxes it into an mrb_value
266
271
  */
267
- #ifndef MRB_WITHOUT_FLOAT
272
+ #ifndef MRB_NO_FLOAT
268
273
  MRB_INLINE mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
269
274
  {
270
275
  mrb_value v;
@@ -284,14 +289,19 @@ mrb_cptr_value(struct mrb_state *mrb, void *p)
284
289
  }
285
290
 
286
291
  /**
287
- * Returns a fixnum in Ruby.
288
- *
289
- * Takes an integer and boxes it into an mrb_value
292
+ * Returns an integer in Ruby.
290
293
  */
294
+ MRB_INLINE mrb_value mrb_int_value(struct mrb_state *mrb, mrb_int i)
295
+ {
296
+ mrb_value v;
297
+ SET_INT_VALUE(mrb, v, i);
298
+ return v;
299
+ }
300
+
291
301
  MRB_INLINE mrb_value mrb_fixnum_value(mrb_int i)
292
302
  {
293
303
  mrb_value v;
294
- SET_INT_VALUE(v, i);
304
+ SET_FIXNUM_VALUE(v, i);
295
305
  return v;
296
306
  }
297
307
 
@@ -35,6 +35,7 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
35
35
  void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
36
36
  mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
37
37
  void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
38
+ size_t mrb_obj_iv_tbl_memsize(mrb_value);
38
39
  MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
39
40
  MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
40
41
  MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
@@ -27,7 +27,7 @@ MRB_BEGIN_DECL
27
27
  /*
28
28
  * The version of Ruby used by mruby.
29
29
  */
30
- #define MRUBY_RUBY_VERSION "2.0"
30
+ #define MRUBY_RUBY_VERSION "3.0"
31
31
 
32
32
  /*
33
33
  * Ruby engine.
@@ -37,17 +37,35 @@ MRB_BEGIN_DECL
37
37
  /*
38
38
  * Major release version number.
39
39
  */
40
- #define MRUBY_RELEASE_MAJOR 2
40
+ #define MRUBY_RELEASE_MAJOR 3
41
41
 
42
42
  /*
43
43
  * Minor release version number.
44
44
  */
45
- #define MRUBY_RELEASE_MINOR 1
45
+ #define MRUBY_RELEASE_MINOR 0
46
46
 
47
47
  /*
48
48
  * Tiny release version number.
49
49
  */
50
- #define MRUBY_RELEASE_TEENY 2
50
+ #define MRUBY_RELEASE_TEENY 0
51
+
52
+ /*
53
+ * Patch level.
54
+ */
55
+ #define MRUBY_PATCHLEVEL -1
56
+
57
+ /*
58
+ * Patch level string. (optional)
59
+ */
60
+ #define MRUBY_PATCHLEVEL_STR ""
61
+
62
+ #ifndef MRUBY_PATCHLEVEL_STR
63
+ # if MRUBY_PATCHLEVEL < 0
64
+ # define MRUBY_PATCHLEVEL_STR "dev"
65
+ # else
66
+ # define MRUBY_PATCHLEVEL_STR "p"MRB_STRINGIZE(MRUBY_PATCHLEVEL)
67
+ # endif
68
+ #endif
51
69
 
52
70
  /*
53
71
  * The mruby version.
@@ -62,17 +80,17 @@ MRB_BEGIN_DECL
62
80
  /*
63
81
  * Release year.
64
82
  */
65
- #define MRUBY_RELEASE_YEAR 2020
83
+ #define MRUBY_RELEASE_YEAR 2021
66
84
 
67
85
  /*
68
86
  * Release month.
69
87
  */
70
- #define MRUBY_RELEASE_MONTH 8
88
+ #define MRUBY_RELEASE_MONTH 3
71
89
 
72
90
  /*
73
91
  * Release day.
74
92
  */
75
- #define MRUBY_RELEASE_DAY 6
93
+ #define MRUBY_RELEASE_DAY 5
76
94
 
77
95
  /*
78
96
  * Release date as a string.
@@ -108,6 +126,7 @@ MRB_BEGIN_DECL
108
126
  */
109
127
  #define MRUBY_DESCRIPTION \
110
128
  "mruby " MRUBY_VERSION \
129
+ MRUBY_PATCHLEVEL_STR \
111
130
  " (" MRUBY_RELEASE_DATE ")" \
112
131
 
113
132
  /*
@@ -1,10 +1,11 @@
1
- require "mruby-core-ext"
1
+ require "mruby/core_ext"
2
2
  require "mruby/build/load_gems"
3
3
  require "mruby/build/command"
4
4
 
5
5
  module MRuby
6
6
  autoload :Gem, "mruby/gem"
7
7
  autoload :Lockfile, "mruby/lockfile"
8
+ autoload :Presym, "mruby/presym"
8
9
 
9
10
  class << self
10
11
  def targets
@@ -22,6 +23,18 @@ def each_target(&block)
22
23
  class Toolchain
23
24
  class << self
24
25
  attr_accessor :toolchains
26
+
27
+ def guess
28
+ if cc = ENV["CC"] || ENV["CXX"]
29
+ return "clang" if cc.include?("clang")
30
+ else
31
+ return "clang" if RUBY_PLATFORM =~ /darwin|(?:free|open)bsd/
32
+ return "gcc" if RUBY_PLATFORM.include?("cygwin")
33
+ return "visualcpp" if ENV.include?("VisualStudioVersion")
34
+ return "visualcpp" if ENV.include?("VSINSTALLDIR")
35
+ end
36
+ "gcc"
37
+ end
25
38
  end
26
39
 
27
40
  def initialize(name, &block)
@@ -29,7 +42,7 @@ def initialize(name, &block)
29
42
  MRuby::Toolchain.toolchains[@name] = self
30
43
  end
31
44
 
32
- def setup(conf,params={})
45
+ def setup(conf, params={})
33
46
  conf.instance_exec(conf, params, &@initializer)
34
47
  end
35
48
 
@@ -39,12 +52,27 @@ def setup(conf,params={})
39
52
  class Build
40
53
  class << self
41
54
  attr_accessor :current
55
+
56
+ def mruby_config_path
57
+ path = ENV['MRUBY_CONFIG'] || ENV['CONFIG']
58
+ if path.nil? || path.empty?
59
+ path = "#{MRUBY_ROOT}/build_config/default.rb"
60
+ elsif !File.file?(path) && !Pathname.new(path).absolute?
61
+ f = "#{MRUBY_ROOT}/build_config/#{path}.rb"
62
+ path = File.exist?(f) ? f : File.extname(path).empty? ? f : path
63
+ end
64
+ path
65
+ end
66
+
67
+ def install_dir
68
+ @install_dir ||= ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
69
+ end
42
70
  end
71
+
43
72
  include Rake::DSL
44
73
  include LoadGems
45
74
  attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
46
- attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url
47
- attr_writer :enable_bintest, :enable_test
75
+ attr_reader :products, :libmruby_core_objs, :libmruby_objs, :gems, :toolchains, :presym, :mrbc_build, :gem_dir_to_repo_url
48
76
 
49
77
  alias libmruby libmruby_objs
50
78
 
@@ -52,16 +80,16 @@ class << self
52
80
  COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
53
81
  attr_block MRuby::Build::COMMANDS
54
82
 
55
- Exts = Struct.new(:object, :executable, :library)
83
+ Exts = Struct.new(:object, :executable, :library, :presym_preprocessed)
56
84
 
57
- def initialize(name='host', build_dir=nil, &block)
85
+ def initialize(name='host', build_dir=nil, internal: false, &block)
58
86
  @name = name.to_s
59
87
 
60
- unless MRuby.targets[@name]
88
+ unless current = MRuby.targets[@name]
61
89
  if ENV['OS'] == 'Windows_NT'
62
- @exts = Exts.new('.o', '.exe', '.a')
90
+ @exts = Exts.new('.o', '.exe', '.a', '.pi')
63
91
  else
64
- @exts = Exts.new('.o', '', '.a')
92
+ @exts = Exts.new('.o', '', '.a', '.pi')
65
93
  end
66
94
 
67
95
  build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
@@ -69,10 +97,10 @@ def initialize(name='host', build_dir=nil, &block)
69
97
  @file_separator = '/'
70
98
  @build_dir = "#{build_dir}/#{@name}"
71
99
  @gem_clone_dir = "#{build_dir}/repos/#{@name}"
72
- @cc = Command::Compiler.new(self, %w(.c))
73
- @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
74
- @objc = Command::Compiler.new(self, %w(.m))
75
- @asm = Command::Compiler.new(self, %w(.S .asm))
100
+ @cc = Command::Compiler.new(self, %w(.c), label: "CC")
101
+ @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp), label: "CXX")
102
+ @objc = Command::Compiler.new(self, %w(.m), label: "OBJC")
103
+ @asm = Command::Compiler.new(self, %w(.S .asm .s), label: "ASM")
76
104
  @linker = Command::Linker.new(self)
77
105
  @archiver = Command::Archiver.new(self)
78
106
  @yacc = Command::Yacc.new(self)
@@ -80,8 +108,12 @@ def initialize(name='host', build_dir=nil, &block)
80
108
  @git = Command::Git.new(self)
81
109
  @mrbc = Command::Mrbc.new(self)
82
110
 
111
+ @products = []
83
112
  @bins = []
84
- @gems, @libmruby_objs = MRuby::Gem::List.new, []
113
+ @gems = MRuby::Gem::List.new
114
+ @libmruby_core_objs = []
115
+ @libmruby_objs = [@libmruby_core_objs]
116
+ @enable_libmruby = true
85
117
  @build_mrbtest_lib_only = false
86
118
  @cxx_exception_enabled = false
87
119
  @cxx_exception_disabled = false
@@ -89,17 +121,33 @@ def initialize(name='host', build_dir=nil, &block)
89
121
  @enable_bintest = false
90
122
  @enable_test = false
91
123
  @enable_lock = true
124
+ @enable_presym = true
125
+ @mrbcfile_external = false
126
+ @internal = internal
92
127
  @toolchains = []
93
128
  @gem_dir_to_repo_url = {}
94
129
 
95
- MRuby.targets[@name] = self
130
+ MRuby.targets[@name] = current = self
131
+ end
132
+
133
+ MRuby::Build.current = current
134
+ current.instance_eval(&block)
135
+ if current.libmruby_enabled? && !current.mrbcfile_external?
136
+ if current.presym_enabled?
137
+ current.create_mrbc_build if current.host? || current.gems["mruby-bin-mrbc"]
138
+ elsif current.host?
139
+ current.build_mrbc_exec
140
+ end
96
141
  end
142
+ current.presym = Presym.new(current) if current.presym_enabled?
143
+ end
97
144
 
98
- MRuby::Build.current = MRuby.targets[@name]
99
- MRuby.targets[@name].instance_eval(&block)
145
+ def libmruby_enabled?
146
+ @enable_libmruby
147
+ end
100
148
 
101
- build_mrbc_exec if name == 'host'
102
- build_mrbtest if test_enabled?
149
+ def disable_libmruby
150
+ @enable_libmruby = false
103
151
  end
104
152
 
105
153
  def debug_enabled?
@@ -118,6 +166,17 @@ def enable_debug
118
166
  @enable_debug = true
119
167
  end
120
168
 
169
+ def presym_enabled?
170
+ @enable_presym
171
+ end
172
+
173
+ def disable_presym
174
+ if @enable_presym
175
+ @enable_presym = false
176
+ compilers.each{|c| c.defines << "MRB_NO_PRESYM"}
177
+ end
178
+ end
179
+
121
180
  def disable_lock
122
181
  @enable_lock = false
123
182
  end
@@ -141,7 +200,7 @@ def enable_cxx_exception
141
200
  end
142
201
  @cxx_exception_enabled = true
143
202
  compilers.each { |c|
144
- c.defines += %w(MRB_ENABLE_CXX_EXCEPTION)
203
+ c.defines += %w(MRB_USE_CXX_EXCEPTION)
145
204
  c.flags << c.cxx_exception_flag
146
205
  }
147
206
  linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
@@ -161,7 +220,7 @@ def enable_cxx_abi
161
220
  raise "cxx_exception already enabled"
162
221
  end
163
222
  compilers.each { |c|
164
- c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI)
223
+ c.defines += %w(MRB_USE_CXX_EXCEPTION MRB_USE_CXX_ABI)
165
224
  c.flags << c.cxx_compile_flag
166
225
  c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten
167
226
  }
@@ -169,8 +228,29 @@ def enable_cxx_abi
169
228
  @cxx_abi_enabled = true
170
229
  end
171
230
 
172
- def compile_as_cxx src, cxx_src, obj = nil, includes = []
173
- obj = objfile(cxx_src) if obj.nil?
231
+ def compile_as_cxx(src, cxx_src = nil, obj = nil, includes = [])
232
+ #
233
+ # If `cxx_src` is specified, this method behaves the same as before as
234
+ # compatibility mode, but `.d` file is not read.
235
+ #
236
+ # If `cxx_src` is omitted, `.d` file is read by using mruby standard
237
+ # Rake rule (C++ source name is also changed).
238
+ #
239
+ if cxx_src
240
+ obj ||= cxx_src + @exts.object
241
+ dsts = [obj]
242
+ dsts << (cxx_src + @exts.presym_preprocessed) if presym_enabled?
243
+ defines = []
244
+ include_paths = ["#{MRUBY_ROOT}/src", *includes]
245
+ dsts.each do |dst|
246
+ file dst => cxx_src do |t|
247
+ cxx.run t.name, t.prerequisites.first, defines, include_paths
248
+ end
249
+ end
250
+ else
251
+ cxx_src = "#{build_dir}/#{src.relative_path})".ext << "-cxx.cxx"
252
+ obj = cxx_src.ext(@exts.object)
253
+ end
174
254
 
175
255
  file cxx_src => [src, __FILE__] do |t|
176
256
  mkdir_p File.dirname t.name
@@ -178,20 +258,16 @@ def compile_as_cxx src, cxx_src, obj = nil, includes = []
178
258
  #define __STDC_CONSTANT_MACROS
179
259
  #define __STDC_LIMIT_MACROS
180
260
 
181
- #ifndef MRB_ENABLE_CXX_ABI
261
+ #ifndef MRB_USE_CXX_ABI
182
262
  extern "C" {
183
263
  #endif
184
264
  #include "#{File.absolute_path src}"
185
- #ifndef MRB_ENABLE_CXX_ABI
265
+ #ifndef MRB_USE_CXX_ABI
186
266
  }
187
267
  #endif
188
268
  EOS
189
269
  end
190
270
 
191
- file obj => cxx_src do |t|
192
- cxx.run t.name, t.prerequisites.first, [], ["#{MRUBY_ROOT}/src"] + includes
193
- end
194
-
195
271
  obj
196
272
  end
197
273
 
@@ -203,7 +279,7 @@ def bintest_enabled?
203
279
  @enable_bintest
204
280
  end
205
281
 
206
- def toolchain(name, params={})
282
+ def toolchain(name=Toolchain.guess, params={})
207
283
  name = name.to_s
208
284
  tc = Toolchain.toolchains[name] || begin
209
285
  path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
@@ -226,17 +302,14 @@ def root
226
302
  def enable_test
227
303
  @enable_test = true
228
304
  end
305
+ alias build_mrbtest enable_test
229
306
 
230
307
  def test_enabled?
231
308
  @enable_test
232
309
  end
233
310
 
234
- def build_mrbtest
235
- gem :core => 'mruby-test'
236
- end
237
-
238
311
  def build_mrbc_exec
239
- gem :core => 'mruby-bin-mrbc'
312
+ gem :core => 'mruby-bin-mrbc' unless @gems['mruby-bin-mrbc']
240
313
  end
241
314
 
242
315
  def locks
@@ -246,9 +319,22 @@ def locks
246
319
  def mrbcfile
247
320
  return @mrbcfile if @mrbcfile
248
321
 
249
- mrbc_build = MRuby.targets['host']
250
- gems.each { |v| mrbc_build = self if v.name == 'mruby-bin-mrbc' }
251
- @mrbcfile = mrbc_build.exefile("#{mrbc_build.build_dir}/bin/mrbc")
322
+ gem_name = "mruby-bin-mrbc"
323
+ gem = @gems[gem_name]
324
+ gem ||= (host = MRuby.targets["host"]) && host.gems[gem_name]
325
+ unless gem
326
+ fail "external mrbc or mruby-bin-mrbc gem in current('#{@name}') or 'host' build is required"
327
+ end
328
+ @mrbcfile = exefile("#{gem.build.build_dir}/bin/mrbc")
329
+ end
330
+
331
+ def mrbcfile=(path)
332
+ @mrbcfile = path
333
+ @mrbcfile_external = true
334
+ end
335
+
336
+ def mrbcfile_external?
337
+ @mrbcfile_external
252
338
  end
253
339
 
254
340
  def compilers
@@ -258,16 +344,34 @@ def compilers
258
344
  end
259
345
 
260
346
  def define_rules
347
+ use_mrdb = @gems["mruby-bin-debugger"]
261
348
  compilers.each do |compiler|
262
349
  if respond_to?(:enable_gems?) && enable_gems?
263
- compiler.defines -= %w(DISABLE_GEMS)
350
+ compiler.defines -= %w(MRB_NO_GEMS)
264
351
  else
265
- compiler.defines += %w(DISABLE_GEMS)
352
+ compiler.defines += %w(MRB_NO_GEMS)
266
353
  end
267
- compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
354
+ compiler.defines |= %w(MRB_USE_DEBUG_HOOK) if use_mrdb
355
+ end
356
+ [@cc, *(@cxx if cxx_exception_enabled?)].each do |compiler|
357
+ compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.object)
358
+ compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.presym_preprocessed) if presym_enabled?
268
359
  end
269
360
  end
270
361
 
362
+ def define_installer(src)
363
+ dst = "#{self.class.install_dir}/#{File.basename(src)}"
364
+ file dst => src do
365
+ install_D src, dst
366
+ end
367
+ dst
368
+ end
369
+
370
+ def define_installer_if_needed(bin)
371
+ exe = exefile("#{build_dir}/bin/#{bin}")
372
+ host? ? define_installer(exe) : exe
373
+ end
374
+
271
375
  def filename(name)
272
376
  if name.is_a?(Array)
273
377
  name.flatten.map { |n| filename(n) }
@@ -326,7 +430,9 @@ def run_bintest
326
430
  puts ">>> Bintest #{name} <<<"
327
431
  targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
328
432
  targets << filename(".") if File.directory? "./bintest"
329
- sh "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
433
+ mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile
434
+ env = {"BUILD_DIR" => @build_dir, "MRBCFILE" => mrbc}
435
+ sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
330
436
  end
331
437
 
332
438
  def print_build_summary
@@ -359,6 +465,42 @@ def libmruby_core_static
359
465
  def libraries
360
466
  [libmruby_static]
361
467
  end
468
+
469
+ def host?
470
+ @name == "host"
471
+ end
472
+
473
+ def internal?
474
+ @internal
475
+ end
476
+
477
+ protected
478
+
479
+ attr_writer :presym
480
+
481
+ def create_mrbc_build
482
+ exclusions = %i[@name @build_dir @gems @enable_test @enable_bintest @internal]
483
+ name = "#{@name}/mrbc"
484
+ MRuby.targets.delete(name)
485
+ build = self.class.new(name, internal: true){}
486
+ build.build_dir = "#{@build_dir}/mrbc"
487
+ instance_variables.each do |n|
488
+ next if exclusions.include?(n)
489
+ v = instance_variable_get(n)
490
+ v = case v
491
+ when nil, true, false, Numeric; v
492
+ when String, Command; v.clone
493
+ else Marshal.load(Marshal.dump(v)) # deep clone
494
+ end
495
+ build.instance_variable_set(n, v)
496
+ end
497
+ build.build_mrbc_exec
498
+ build.disable_libmruby
499
+ build.disable_presym
500
+ @mrbc_build = build
501
+ self.mrbcfile = build.mrbcfile
502
+ build
503
+ end
362
504
  end # Build
363
505
 
364
506
  class CrossBuild < Build
@@ -369,13 +511,21 @@ class CrossBuild < Build
369
511
  attr_accessor :host_target, :build_target
370
512
 
371
513
  def initialize(name, build_dir=nil, &block)
372
- @endian = nil
373
514
  @test_runner = Command::CrossTestRunner.new(self)
374
515
  super
516
+ unless mrbcfile_external? || MRuby.targets['host']
517
+ # add minimal 'host'
518
+ MRuby::Build.new('host') do |conf|
519
+ conf.toolchain
520
+ conf.build_mrbc_exec
521
+ conf.disable_libmruby
522
+ conf.disable_presym
523
+ end
524
+ end
375
525
  end
376
526
 
377
527
  def mrbcfile
378
- MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/mrbc")
528
+ mrbcfile_external? ? super : MRuby::targets['host'].mrbcfile
379
529
  end
380
530
 
381
531
  def run_test
@@ -388,5 +538,9 @@ def run_test
388
538
  @test_runner.run(mrbtest)
389
539
  end
390
540
  end
541
+
542
+ protected
543
+
544
+ def create_mrbc_build; end
391
545
  end # CrossBuild
392
546
  end # MRuby