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
@@ -13,7 +13,7 @@ def self.test(rubysource, testcase)
13
13
  script.flush
14
14
 
15
15
  # compile
16
- `./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`
16
+ `#{cmd("mrbc")} -g -o "#{bin.path}" "#{script.path}"`
17
17
 
18
18
  # add mrdb quit
19
19
  testcase << {:cmd=>"quit"}
@@ -21,7 +21,7 @@ def self.test(rubysource, testcase)
21
21
  stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n"
22
22
 
23
23
  prompt = /^\(#{Regexp.escape(script.path)}:\d+\) /
24
- ["bin/mrdb #{script.path}","bin/mrdb -b #{bin.path}"].each do |cmd|
24
+ ["#{cmd('mrdb')} #{script.path}", "#{cmd('mrdb')} -b #{bin.path}"].each do |cmd|
25
25
  o, s = Open3.capture2(cmd, :stdin_data => stdin_data)
26
26
  scanner = StringScanner.new(o)
27
27
  scanner.skip_until(prompt)
@@ -67,7 +67,7 @@ def self.test(rubysource, testcase)
67
67
  BinTest_MrubyBinDebugger.test(src, tc)
68
68
  end
69
69
 
70
- assert('mruby-bin-debugger(print) nomal') do
70
+ assert('mruby-bin-debugger(print) normal') do
71
71
  # ruby source
72
72
  src = <<"SRC"
73
73
  foo = 'foo'
@@ -99,7 +99,7 @@ def self.test(rubysource, testcase)
99
99
  BinTest_MrubyBinDebugger.test(src, tc)
100
100
  end
101
101
 
102
- # Kernel#instance_eval(string) does't work multiple statements.
102
+ # Kernel#instance_eval(string) doesn't work multiple statements.
103
103
  =begin
104
104
  assert('mruby-bin-debugger(print) multiple statements') do
105
105
  # ruby source
@@ -234,7 +234,7 @@ def m
234
234
  BinTest_MrubyBinDebugger.test(src, tc)
235
235
  end
236
236
 
237
- assert('mruby-bin-debugger(print) same name:local variabe') do
237
+ assert('mruby-bin-debugger(print) same name:local variable') do
238
238
  # ruby source (bp is break point)
239
239
  src = <<"SRC"
240
240
  lv = 'top'
@@ -516,7 +516,7 @@ def m
516
516
  tc << {:cmd=>'p a+1', :exp=>'$1 = 2'}
517
517
  tc << {:cmd=>'p 2-b', :exp=>'$2 = -3'}
518
518
  tc << {:cmd=>'p c * 3', :exp=>'$3 = 24'}
519
- tc << {:cmd=>'p a/b', :exp=>'$4 = 0.2'}
519
+ tc << {:cmd=>'p a/b', :exp=>'$4 = 0'}
520
520
  tc << {:cmd=>'p c%b', :exp=>'$5 = 3'}
521
521
  tc << {:cmd=>'p 2**10', :exp=>'$6 = 1024'}
522
522
  tc << {:cmd=>'p ~3', :exp=>'$7 = -4'}
@@ -614,13 +614,13 @@ def m
614
614
  tc << {:cmd=>'p a+=9', :exp=>'$1 = 10'}
615
615
  tc << {:cmd=>'p b-=c', :exp=>'$2 = 15'}
616
616
  tc << {:cmd=>'p bar*=2', :exp=>'$3 = "barbar"'}
617
- tc << {:cmd=>'p a/=4', :exp=>'$4 = 2.5'}
617
+ tc << {:cmd=>'p a/=4', :exp=>'$4 = 2'}
618
618
  tc << {:cmd=>'p c%=4', :exp=>'$5 = 2'}
619
619
 
620
620
  tc << {:cmd=>'p b&=0b0101', :exp=>'$6 = 5'}
621
621
  tc << {:cmd=>'p c|=0x10', :exp=>'$7 = 18'}
622
622
 
623
- tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2.5 5 18"'}
623
+ tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2 5 18"'}
624
624
  tc << {:cmd=>'p "#{foo}#{bar}#{baz}"', :exp=>'$9 = "foobarbarbaz"'}
625
625
 
626
626
  tc << {:cmd=>'p a,b,c=[10,20,30]',:exp=>'$10 = [10, 20, 30]'}
@@ -682,13 +682,13 @@ def m
682
682
  tc << {:cmd=>'p a+=9', :exp=>'$1 = 10'}
683
683
  tc << {:cmd=>'p b-=c', :exp=>'$2 = 15'}
684
684
  tc << {:cmd=>'p bar*=2', :exp=>'$3 = "barbar"'}
685
- tc << {:cmd=>'p a/=4', :exp=>'$4 = 2.5'}
685
+ tc << {:cmd=>'p a/=4', :exp=>'$4 = 2'}
686
686
  tc << {:cmd=>'p c%=4', :exp=>'$5 = 2'}
687
687
 
688
688
  tc << {:cmd=>'p b&=0b0101', :exp=>'$6 = 5'}
689
689
  tc << {:cmd=>'p c|=0x10', :exp=>'$7 = 18'}
690
690
 
691
- tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2.5 5 18"'}
691
+ tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2 5 18"'}
692
692
  tc << {:cmd=>'p "#{foo}#{bar}#{baz}"', :exp=>'$9 = "foobarbarbaz"'}
693
693
 
694
694
  tc << {:cmd=>'p a,b,c=[10,20,30]',:exp=>'$10 = [10, 20, 30]'}
@@ -84,7 +84,7 @@ free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
84
84
  }
85
85
 
86
86
  static uint16_t
87
- check_file_lineno(mrb_state *mrb, struct mrb_irep *irep, const char *file, uint16_t lineno)
87
+ check_file_lineno(mrb_state *mrb, const struct mrb_irep *irep, const char *file, uint16_t lineno)
88
88
  {
89
89
  mrb_irep_debug_info_file *info_file;
90
90
  uint16_t result = 0;
@@ -151,7 +151,7 @@ compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *cl
151
151
  }
152
152
 
153
153
  sc = mrb_class_get(mrb, method_p->class_name);
154
- ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
154
+ ssym = mrb_intern_check_cstr(mrb, method_p->method_name);
155
155
  m = mrb_method_search_vm(mrb, &sc, ssym);
156
156
  if (MRB_METHOD_UNDEF_P(m)) {
157
157
  return MRB_DEBUG_OK;
@@ -173,6 +173,7 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
173
173
  int32_t index;
174
174
  char* set_file;
175
175
  uint16_t result;
176
+ size_t len;
176
177
 
177
178
  if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
178
179
  return MRB_DEBUG_INVALID_ARGUMENT;
@@ -195,7 +196,8 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
195
196
  return MRB_DEBUG_BREAK_INVALID_LINENO;
196
197
  }
197
198
 
198
- set_file = (char*)mrb_malloc(mrb, strlen(file) + 1);
199
+ len = strlen(file) + 1;
200
+ set_file = (char*)mrb_malloc(mrb, len);
199
201
 
200
202
  index = dbg->bpnum;
201
203
  dbg->bp[index].bpno = dbg->next_bpno;
@@ -205,7 +207,7 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
205
207
  dbg->bp[index].point.linepoint.lineno = lineno;
206
208
  dbg->bpnum++;
207
209
 
208
- strncpy(set_file, file, strlen(file) + 1);
210
+ strncpy(set_file, file, len);
209
211
 
210
212
  dbg->bp[index].point.linepoint.file = set_file;
211
213
 
@@ -218,6 +220,7 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c
218
220
  int32_t index;
219
221
  char* set_class;
220
222
  char* set_method;
223
+ size_t len;
221
224
 
222
225
  if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
223
226
  return MRB_DEBUG_INVALID_ARGUMENT;
@@ -232,16 +235,18 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c
232
235
  }
233
236
 
234
237
  if (class_name != NULL) {
235
- set_class = (char*)mrb_malloc(mrb, strlen(class_name) + 1);
236
- strncpy(set_class, class_name, strlen(class_name) + 1);
238
+ len = strlen(class_name) + 1;
239
+ set_class = (char*)mrb_malloc(mrb, len);
240
+ strncpy(set_class, class_name, len);
237
241
  }
238
242
  else {
239
243
  set_class = NULL;
240
244
  }
241
245
 
242
- set_method = (char*)mrb_malloc(mrb, strlen(method_name) + 1);
246
+ len = strlen(method_name) + 1;
247
+ set_method = (char*)mrb_malloc(mrb, len);
243
248
 
244
- strncpy(set_method, method_name, strlen(method_name) + 1);
249
+ strncpy(set_method, method_name, len);
245
250
 
246
251
  index = dbg->bpnum;
247
252
  dbg->bp[index].bpno = dbg->next_bpno;
@@ -428,7 +433,7 @@ mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
428
433
  }
429
434
 
430
435
  static mrb_bool
431
- check_start_pc_for_line(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, uint16_t line)
436
+ check_start_pc_for_line(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc, uint16_t line)
432
437
  {
433
438
  if (pc > irep->iseq) {
434
439
  if (line == mrb_debug_get_line(mrb, irep, pc - irep->iseq - 1)) {
@@ -11,6 +11,7 @@
11
11
  #include <mruby/error.h>
12
12
  #include <mruby/numeric.h>
13
13
  #include <mruby/string.h>
14
+ #include <mruby/presym.h>
14
15
  #include "apiprint.h"
15
16
 
16
17
  static void
@@ -33,7 +34,7 @@ mrdb_check_syntax(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size
33
34
  mrb_value
34
35
  mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len, mrb_bool *exc, int direct_eval)
35
36
  {
36
- void (*tmp)(struct mrb_state *, struct mrb_irep *, const mrb_code *, mrb_value *);
37
+ void (*tmp)(struct mrb_state *, const struct mrb_irep *, const mrb_code *, mrb_value *);
37
38
  mrb_value ruby_code;
38
39
  mrb_value s;
39
40
  mrb_value v;
@@ -67,7 +68,7 @@ mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t
67
68
 
68
69
  recv = dbg->regs[0];
69
70
 
70
- v = mrb_funcall(mrb, recv, "instance_eval", 1, ruby_code);
71
+ v = mrb_funcall_id(mrb, recv, MRB_SYM(instance_eval), 1, ruby_code);
71
72
  }
72
73
 
73
74
  if (exc) {
@@ -13,6 +13,7 @@
13
13
  #include <mruby/class.h>
14
14
  #include <mruby/opcode.h>
15
15
  #include <mruby/variable.h>
16
+ #include <mruby/proc.h>
16
17
 
17
18
  #include "mrdb.h"
18
19
  #include "apibreak.h"
@@ -504,7 +505,7 @@ get_and_parse_command(mrb_state *mrb, mrdb_state *mrdb)
504
505
  }
505
506
 
506
507
  static int32_t
507
- check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, mrb_value *regs)
508
+ check_method_breakpoint(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc, mrb_value *regs)
508
509
  {
509
510
  struct RClass* c;
510
511
  mrb_sym sym;
@@ -526,7 +527,7 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, mrb_
526
527
  sym = irep->syms[insn.b];
527
528
  break;
528
529
  case OP_SUPER:
529
- c = mrb->c->ci->target_class->super;
530
+ c = mrb_vm_ci_target_class(mrb->c->ci)->super;
530
531
  sym = mrb->c->ci->mid;
531
532
  break;
532
533
  default:
@@ -545,7 +546,7 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, mrb_
545
546
  }
546
547
 
547
548
  static void
548
- mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, mrb_value *regs)
549
+ mrb_code_fetch_hook(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc, mrb_value *regs)
549
550
  {
550
551
  const char *file;
551
552
  int32_t line;
@@ -10,10 +10,6 @@
10
10
 
11
11
  #include "mrdbconf.h"
12
12
 
13
- #ifdef _MSC_VER
14
- # define __func__ __FUNCTION__
15
- #endif
16
-
17
13
  #define MAX_COMMAND_WORD (16)
18
14
 
19
15
  typedef enum debug_command_id {
@@ -103,8 +99,8 @@ typedef struct mrb_debug_breakpoint {
103
99
  } mrb_debug_breakpoint;
104
100
 
105
101
  typedef struct mrb_debug_context {
106
- struct mrb_irep *root_irep;
107
- struct mrb_irep *irep;
102
+ const struct mrb_irep *root_irep;
103
+ const struct mrb_irep *irep;
108
104
  const mrb_code *pc;
109
105
  mrb_value *regs;
110
106
 
@@ -6,12 +6,12 @@
6
6
  #ifndef MRDBCONF_H
7
7
  #define MRDBCONF_H
8
8
 
9
- #ifndef MRB_ENABLE_DEBUG_HOOK
10
- # error mruby-bin-debugger need 'MRB_ENABLE_DEBUG_HOOK' configuration in your 'build_config.rb'
9
+ #ifndef MRB_USE_DEBUG_HOOK
10
+ # error mruby-bin-debugger need 'MRB_USE_DEBUG_HOOK' in your build configuration
11
11
  #endif
12
12
 
13
- #ifdef MRB_DISABLE_STDIO
14
- # error mruby-bin-debugger conflicts 'MRB_DISABLE_STDIO' configuration in your 'build_config.rb'
13
+ #ifdef MRB_NO_STDIO
14
+ # error mruby-bin-debugger conflicts 'MRB_NO_STDIO' in your build configuration
15
15
  #endif
16
16
 
17
17
  /* configuration options: */
@@ -1,20 +1,21 @@
1
1
  require 'open3'
2
+ require 'tempfile'
2
3
 
3
4
  assert('mirb normal operations') do
4
- o, s = Open3.capture2('bin/mirb', :stdin_data => "a=1\nb=2\na+b\n")
5
+ o, s = Open3.capture2(cmd("mirb"), :stdin_data => "a=1\nb=2\na+b\n")
5
6
  assert_true o.include?('=> 3')
6
7
  assert_true o.include?('=> 2')
7
8
  end
8
9
 
9
10
  assert('regression for #1563') do
10
- o, s = Open3.capture2('bin/mirb', :stdin_data => "a=1;b=2;c=3\nb\nc")
11
+ o, s = Open3.capture2(cmd("mirb"), :stdin_data => "a=1;b=2;c=3\nb\nc")
11
12
  assert_true o.include?('=> 3')
12
13
  end
13
14
 
14
15
  assert('mirb -d option') do
15
- o, _ = Open3.capture2('bin/mirb', :stdin_data => "$DEBUG\n")
16
+ o, _ = Open3.capture2(cmd("mirb"), :stdin_data => "$DEBUG\n")
16
17
  assert_true o.include?('=> false')
17
- o, _ = Open3.capture2('bin/mirb -d', :stdin_data => "$DEBUG\n")
18
+ o, _ = Open3.capture2("#{cmd('mirb')} -d", :stdin_data => "$DEBUG\n")
18
19
  assert_true o.include?('=> true')
19
20
  end
20
21
 
@@ -29,6 +30,23 @@ def hoge
29
30
  EOS
30
31
  lib.flush
31
32
 
32
- o, _ = Open3.capture2("bin/mirb -r #{lib.path}", :stdin_data => "Hoge.new.hoge\n")
33
+ o, _ = Open3.capture2("#{cmd('mirb')} -r #{lib.path}", :stdin_data => "Hoge.new.hoge\n")
33
34
  assert_true o.include?('=> :hoge')
34
35
  end
36
+
37
+ assert('top level local variables are in file scope') do
38
+ lib = Tempfile.new('lib.rb')
39
+ lib.write <<-TESTLIB
40
+ a = 1
41
+ A = -> { a }
42
+ TESTLIB
43
+ lib.flush
44
+
45
+ o, _ = Open3.capture2("#{cmd('mirb')} -r #{lib.path}", :stdin_data => <<-TESTCODE)
46
+ a
47
+ a = 5
48
+ A.call
49
+ TESTCODE
50
+
51
+ assert_kind_of Integer, o =~ /\bundefined method 'a' \(NoMethodError\).*=> 5\b.*=> 1\b/m
52
+ end
@@ -4,7 +4,7 @@
4
4
  spec.summary = 'mirb command'
5
5
 
6
6
  if spec.build.cc.search_header_path 'readline/readline.h'
7
- spec.cc.defines << "ENABLE_READLINE"
7
+ spec.cc.defines << "MRB_USE_READLINE"
8
8
  if spec.build.cc.search_header_path 'termcap.h'
9
9
  if MRUBY_BUILD_HOST_IS_CYGWIN || MRUBY_BUILD_HOST_IS_OPENBSD
10
10
  if spec.build.cc.search_header_path 'termcap.h'
@@ -20,12 +20,21 @@
20
20
  spec.linker.libraries << 'edit'
21
21
  else
22
22
  spec.linker.libraries << 'readline'
23
+ if RUBY_PLATFORM.include?('darwin')
24
+ # Workaround to build with Homebrew's readline on Mac (#4537)
25
+ lib_path = spec.build.cc.header_search_paths.find do |include_path|
26
+ lib_path = File.expand_path("#{include_path}/../lib")
27
+ break lib_path if File.exist?("#{lib_path}/libreadline.dylib") ||
28
+ File.exist?("#{lib_path}/libreadline.a")
29
+ end
30
+ spec.linker.library_paths << lib_path if lib_path
31
+ end
23
32
  if spec.build.cc.search_header_path 'curses.h'
24
33
  spec.linker.libraries << 'ncurses'
25
34
  end
26
35
  end
27
36
  elsif spec.build.cc.search_header_path 'linenoise.h'
28
- spec.cc.defines << "ENABLE_LINENOISE"
37
+ spec.cc.defines << "MRB_USE_LINENOISE"
29
38
  end
30
39
 
31
40
  spec.bins = %w(mirb)
@@ -8,8 +8,8 @@
8
8
 
9
9
  #include <mruby.h>
10
10
 
11
- #ifdef MRB_DISABLE_STDIO
12
- # error mruby-bin-mirb conflicts 'MRB_DISABLE_STDIO' configuration in your 'build_config.rb'
11
+ #ifdef MRB_NO_STDIO
12
+ # error mruby-bin-mirb conflicts 'MRB_NO_STDIO' in your build configuration
13
13
  #endif
14
14
 
15
15
  #include <mruby/array.h>
@@ -18,7 +18,7 @@
18
18
  #include <mruby/dump.h>
19
19
  #include <mruby/string.h>
20
20
  #include <mruby/variable.h>
21
- #include <mruby/throw.h>
21
+ #include <mruby/presym.h>
22
22
 
23
23
  #include <stdlib.h>
24
24
  #include <string.h>
@@ -27,7 +27,18 @@
27
27
  #include <signal.h>
28
28
  #include <setjmp.h>
29
29
 
30
+ /* obsolete configuration */
30
31
  #ifdef ENABLE_READLINE
32
+ # define MRB_USE_READLINE
33
+ #endif
34
+ #ifdef ENABLE_LINENOISE
35
+ # define MRB_USE_LINENOISE
36
+ #endif
37
+ #ifdef DISABLE_MIRB_UNDERSCORE
38
+ # define MRB_NO_MIRB_UNDERSCORE
39
+ #endif
40
+
41
+ #ifdef MRB_USE_READLINE
31
42
  #include <readline/readline.h>
32
43
  #include <readline/history.h>
33
44
  #define MIRB_ADD_HISTORY(line) add_history(line)
@@ -41,8 +52,8 @@
41
52
  #define MIRB_WRITE_HISTORY(path) write_history(path)
42
53
  #define MIRB_READ_HISTORY(path) read_history(path)
43
54
  #define MIRB_USING_HISTORY() using_history()
44
- #elif defined(ENABLE_LINENOISE)
45
- #define ENABLE_READLINE
55
+ #elif defined(MRB_USE_LINENOISE)
56
+ #define MRB_USE_READLINE
46
57
  #include <linenoise.h>
47
58
  #define MIRB_ADD_HISTORY(line) linenoiseHistoryAdd(line)
48
59
  #define MIRB_READLINE(ch) linenoise(ch)
@@ -62,7 +73,7 @@
62
73
  #define SIGJMP_BUF jmp_buf
63
74
  #endif
64
75
 
65
- #ifdef ENABLE_READLINE
76
+ #ifdef MRB_USE_READLINE
66
77
 
67
78
  static const char history_file_name[] = ".mirb_history";
68
79
 
@@ -104,13 +115,13 @@ p(mrb_state *mrb, mrb_value obj, int prompt)
104
115
  mrb_value val;
105
116
  char* msg;
106
117
 
107
- val = mrb_funcall(mrb, obj, "inspect", 0);
118
+ val = mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0);
108
119
  if (prompt) {
109
120
  if (!mrb->exc) {
110
121
  fputs(" => ", stdout);
111
122
  }
112
123
  else {
113
- val = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0);
124
+ val = mrb_funcall_id(mrb, mrb_obj_value(mrb->exc), MRB_SYM(inspect), 0);
114
125
  }
115
126
  }
116
127
  if (!mrb_string_p(val)) {
@@ -353,7 +364,7 @@ print_hint(void)
353
364
  printf("mirb - Embeddable Interactive Ruby Shell\n\n");
354
365
  }
355
366
 
356
- #ifndef ENABLE_READLINE
367
+ #ifndef MRB_USE_READLINE
357
368
  /* Print the command line prompt of the REPL */
358
369
  static void
359
370
  print_cmdline(int code_block_open)
@@ -394,7 +405,7 @@ check_keyword(const char *buf, const char *word)
394
405
  }
395
406
 
396
407
 
397
- #ifndef ENABLE_READLINE
408
+ #ifndef MRB_USE_READLINE
398
409
  volatile sig_atomic_t input_canceled = 0;
399
410
  void
400
411
  ctrl_c_handler(int signo)
@@ -410,7 +421,7 @@ ctrl_c_handler(int signo)
410
421
  }
411
422
  #endif
412
423
 
413
- #ifndef DISABLE_MIRB_UNDERSCORE
424
+ #ifndef MRB_NO_MIRB_UNDERSCORE
414
425
  void decl_lv_underscore(mrb_state *mrb, mrbc_context *cxt)
415
426
  {
416
427
  struct RProc *proc;
@@ -435,7 +446,7 @@ main(int argc, char **argv)
435
446
  {
436
447
  char ruby_code[4096] = { 0 };
437
448
  char last_code_line[1024] = { 0 };
438
- #ifndef ENABLE_READLINE
449
+ #ifndef MRB_USE_READLINE
439
450
  int last_char;
440
451
  size_t char_index;
441
452
  #else
@@ -479,7 +490,7 @@ main(int argc, char **argv)
479
490
  mrb_define_global_const(mrb, "ARGV", ARGV);
480
491
  mrb_gv_set(mrb, mrb_intern_lit(mrb, "$DEBUG"), mrb_bool_value(args.debug));
481
492
 
482
- #ifdef ENABLE_READLINE
493
+ #ifdef MRB_USE_READLINE
483
494
  history_path = get_history_path(mrb);
484
495
  if (history_path == NULL) {
485
496
  fputs("failed to get history path\n", stderr);
@@ -495,12 +506,9 @@ main(int argc, char **argv)
495
506
 
496
507
  cxt = mrbc_context_new(mrb);
497
508
 
498
- #ifndef DISABLE_MIRB_UNDERSCORE
499
- decl_lv_underscore(mrb, cxt);
500
- #endif
501
-
502
509
  /* Load libraries */
503
510
  for (i = 0; i < args.libc; i++) {
511
+ struct REnv *e;
504
512
  FILE *lfp = fopen(args.libv[i], "r");
505
513
  if (lfp == NULL) {
506
514
  printf("Cannot open library file. (%s)\n", args.libv[i]);
@@ -509,8 +517,16 @@ main(int argc, char **argv)
509
517
  }
510
518
  mrb_load_file_cxt(mrb, lfp, cxt);
511
519
  fclose(lfp);
520
+ e = mrb_vm_ci_env(mrb->c->cibase);
521
+ mrb_vm_ci_env_set(mrb->c->cibase, NULL);
522
+ mrb_env_unshare(mrb, e);
523
+ mrbc_cleanup_local_variables(mrb, cxt);
512
524
  }
513
525
 
526
+ #ifndef MRB_NO_MIRB_UNDERSCORE
527
+ decl_lv_underscore(mrb, cxt);
528
+ #endif
529
+
514
530
  cxt->capture_errors = TRUE;
515
531
  cxt->lineno = 1;
516
532
  mrbc_filename(mrb, cxt, "(mirb)");
@@ -520,17 +536,14 @@ main(int argc, char **argv)
520
536
 
521
537
  while (TRUE) {
522
538
  char *utf8;
523
- struct mrb_jmpbuf c_jmp;
524
539
 
525
- MRB_TRY(&c_jmp);
526
- mrb->jmp = &c_jmp;
527
540
  if (args.rfp) {
528
541
  if (fgets(last_code_line, sizeof(last_code_line)-1, args.rfp) != NULL)
529
542
  goto done;
530
543
  break;
531
544
  }
532
545
 
533
- #ifndef ENABLE_READLINE
546
+ #ifndef MRB_USE_READLINE
534
547
  print_cmdline(code_block_open);
535
548
 
536
549
  signal(SIGINT, ctrl_c_handler);
@@ -638,17 +651,16 @@ main(int argc, char **argv)
638
651
  /* generate bytecode */
639
652
  struct RProc *proc = mrb_generate_code(mrb, parser);
640
653
  if (proc == NULL) {
641
- fputs("codegen error\n", stderr);
642
654
  mrb_parser_free(parser);
643
- break;
655
+ continue;
644
656
  }
645
657
 
646
658
  if (args.verbose) {
647
659
  mrb_codedump_all(mrb, proc);
648
660
  }
649
661
  /* adjust stack length of toplevel environment */
650
- if (mrb->c->cibase->env) {
651
- struct REnv *e = mrb->c->cibase->env;
662
+ if (mrb->c->cibase->u.env) {
663
+ struct REnv *e = mrb_vm_ci_env(mrb->c->cibase);
652
664
  if (e && MRB_ENV_LEN(e) < proc->body.irep->nlocals) {
653
665
  MRB_ENV_SET_LEN(e, proc->body.irep->nlocals);
654
666
  }
@@ -667,12 +679,12 @@ main(int argc, char **argv)
667
679
  }
668
680
  else {
669
681
  /* no */
670
- if (!mrb_respond_to(mrb, result, mrb_intern_lit(mrb, "inspect"))){
682
+ if (!mrb_respond_to(mrb, result, MRB_SYM(inspect))){
671
683
  result = mrb_any_to_s(mrb, result);
672
684
  }
673
685
  p(mrb, result, 1);
674
- #ifndef DISABLE_MIRB_UNDERSCORE
675
- *(mrb->c->stack + 1) = result;
686
+ #ifndef MRB_NO_MIRB_UNDERSCORE
687
+ *(mrb->c->ci->stack + 1) = result;
676
688
  #endif
677
689
  }
678
690
  }
@@ -682,14 +694,9 @@ main(int argc, char **argv)
682
694
  }
683
695
  mrb_parser_free(parser);
684
696
  cxt->lineno++;
685
- MRB_CATCH(&c_jmp) {
686
- p(mrb, mrb_obj_value(mrb->exc), 0);
687
- mrb->exc = 0;
688
- }
689
- MRB_END_EXC(&c_jmp);
690
697
  }
691
698
 
692
- #ifdef ENABLE_READLINE
699
+ #ifdef MRB_USE_READLINE
693
700
  MIRB_WRITE_HISTORY(history_path);
694
701
  mrb_free(mrb, history_path);
695
702
  #endif