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
@@ -9,6 +9,7 @@
9
9
  #include <mruby/numeric.h>
10
10
  #include <mruby/string.h>
11
11
  #include <mruby/class.h>
12
+ #include <mruby/presym.h>
12
13
 
13
14
  MRB_API mrb_bool
14
15
  mrb_obj_eq(mrb_state *mrb, mrb_value v1, mrb_value v2)
@@ -19,12 +20,12 @@ mrb_obj_eq(mrb_state *mrb, mrb_value v1, mrb_value v2)
19
20
  return TRUE;
20
21
 
21
22
  case MRB_TT_FALSE:
22
- case MRB_TT_FIXNUM:
23
- return (mrb_fixnum(v1) == mrb_fixnum(v2));
23
+ case MRB_TT_INTEGER:
24
+ return (mrb_integer(v1) == mrb_integer(v2));
24
25
  case MRB_TT_SYMBOL:
25
26
  return (mrb_symbol(v1) == mrb_symbol(v2));
26
27
 
27
- #ifndef MRB_WITHOUT_FLOAT
28
+ #ifndef MRB_NO_FLOAT
28
29
  case MRB_TT_FLOAT:
29
30
  return (mrb_float(v1) == mrb_float(v2));
30
31
  #endif
@@ -47,18 +48,18 @@ mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
47
48
  mrb_value result;
48
49
 
49
50
  if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
50
- #ifndef MRB_WITHOUT_FLOAT
51
+ #ifndef MRB_NO_FLOAT
51
52
  /* value mixing with integer and float */
52
- if (mrb_fixnum_p(obj1)) {
53
- if (mrb_float_p(obj2) && (mrb_float)mrb_fixnum(obj1) == mrb_float(obj2))
53
+ if (mrb_integer_p(obj1)) {
54
+ if (mrb_float_p(obj2) && (mrb_float)mrb_integer(obj1) == mrb_float(obj2))
54
55
  return TRUE;
55
56
  }
56
57
  else if (mrb_float_p(obj1)) {
57
- if (mrb_fixnum_p(obj2) && mrb_float(obj1) == (mrb_float)mrb_fixnum(obj2))
58
+ if (mrb_integer_p(obj2) && mrb_float(obj1) == (mrb_float)mrb_integer(obj2))
58
59
  return TRUE;
59
60
  }
60
61
  #endif
61
- result = mrb_funcall(mrb, obj1, "==", 1, obj2);
62
+ result = mrb_funcall_id(mrb, obj1, MRB_OPSYM(eq), 1, obj2);
62
63
  if (mrb_test(result)) return TRUE;
63
64
  return FALSE;
64
65
  }
@@ -94,7 +95,7 @@ mrb_true(mrb_state *mrb, mrb_value obj)
94
95
  static mrb_value
95
96
  nil_to_s(mrb_state *mrb, mrb_value obj)
96
97
  {
97
- mrb_value str = mrb_str_new_frozen(mrb, 0, 0);
98
+ mrb_value str = mrb_str_new_frozen(mrb, NULL, 0);
98
99
  RSTR_SET_ASCII_FLAG(mrb_str_ptr(str));
99
100
  return str;
100
101
  }
@@ -315,109 +316,115 @@ mrb_init_object(mrb_state *mrb)
315
316
  mrb_define_method(mrb, f, "inspect", false_to_s, MRB_ARGS_NONE());
316
317
  }
317
318
 
318
- static mrb_value
319
- convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *method, mrb_bool raise)
319
+ static const struct types {
320
+ const enum mrb_vtype type;
321
+ const char *name;
322
+ } builtin_types[] = {
323
+ /* {MRB_TT_NIL, "nil"}, */
324
+ {MRB_TT_FALSE, "false"},
325
+ {MRB_TT_TRUE, "true"},
326
+ {MRB_TT_INTEGER,"Integer"},
327
+ {MRB_TT_SYMBOL, "Symbol"}, /* :symbol */
328
+ {MRB_TT_MODULE, "Module"},
329
+ {MRB_TT_OBJECT, "Object"},
330
+ {MRB_TT_CLASS, "Class"},
331
+ {MRB_TT_ICLASS, "iClass"}, /* internal use: mixed-in module holder */
332
+ {MRB_TT_SCLASS, "SClass"},
333
+ {MRB_TT_PROC, "Proc"},
334
+ #ifndef MRB_NO_FLOAT
335
+ {MRB_TT_FLOAT, "Float"},
336
+ #endif
337
+ {MRB_TT_ARRAY, "Array"},
338
+ {MRB_TT_HASH, "Hash"},
339
+ {MRB_TT_STRING, "String"},
340
+ {MRB_TT_RANGE, "Range"},
341
+ /* {MRB_TT_BIGNUM, "Bignum"}, */
342
+ {MRB_TT_DATA, "Data"}, /* internal use: wrapped C pointers */
343
+ /* {MRB_TT_UNDEF, "undef"}, */ /* internal use: #undef; should not happen */
344
+ {MRB_TT_MAXDEFINE, 0}
345
+ };
346
+
347
+ static const char*
348
+ type_name(enum mrb_vtype t)
320
349
  {
321
- mrb_sym m = 0;
350
+ const struct types *type = builtin_types;
351
+
352
+ while (type->type < MRB_TT_MAXDEFINE) {
353
+ if (type->type == t) return type->name;
354
+ type++;
355
+ }
356
+ return NULL;
357
+ }
322
358
 
323
- m = mrb_intern_cstr(mrb, method);
324
- if (!mrb_respond_to(mrb, val, m)) {
359
+ static mrb_value
360
+ convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, mrb_bool raise)
361
+ {
362
+ if (!mrb_respond_to(mrb, val, method)) {
325
363
  if (raise) {
326
- mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y into %s", val, tname);
364
+ if (tname) mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y into %s", val, tname);
365
+ mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y", val);
327
366
  }
328
367
  return mrb_nil_value();
329
368
  }
330
- return mrb_funcall_argv(mrb, val, m, 0, 0);
369
+ return mrb_funcall_argv(mrb, val, method, 0, 0);
331
370
  }
332
371
 
333
372
  MRB_API mrb_value
334
- mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method)
373
+ mrb_type_convert(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
335
374
  {
336
375
  mrb_value v;
376
+ const char *tname;
337
377
 
338
378
  if (mrb_type(val) == type) return val;
379
+ tname = type_name(type);
339
380
  v = convert_type(mrb, val, tname, method, TRUE);
340
381
  if (mrb_type(v) != type) {
341
- mrb_raisef(mrb, E_TYPE_ERROR, "%v cannot be converted to %s by #%s", val, tname, method);
382
+ if (type == MRB_TT_STRING) return mrb_any_to_s(mrb, val);
383
+ mrb_raisef(mrb, E_TYPE_ERROR, "%v cannot be converted to %s by #%n", val, tname, method);
342
384
  }
343
385
  return v;
344
386
  }
345
387
 
346
388
  MRB_API mrb_value
347
- mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method)
389
+ mrb_type_convert_check(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
348
390
  {
349
391
  mrb_value v;
350
392
 
351
393
  if (mrb_type(val) == type && type != MRB_TT_DATA && type != MRB_TT_ISTRUCT) return val;
352
- v = convert_type(mrb, val, tname, method, FALSE);
394
+ v = convert_type(mrb, val, type_name(type), method, FALSE);
353
395
  if (mrb_nil_p(v) || mrb_type(v) != type) return mrb_nil_value();
354
396
  return v;
355
397
  }
356
398
 
357
- static const struct types {
358
- unsigned char type;
359
- const char *name;
360
- } builtin_types[] = {
361
- /* {MRB_TT_NIL, "nil"}, */
362
- {MRB_TT_FALSE, "false"},
363
- {MRB_TT_TRUE, "true"},
364
- {MRB_TT_FIXNUM, "Fixnum"},
365
- {MRB_TT_SYMBOL, "Symbol"}, /* :symbol */
366
- {MRB_TT_MODULE, "Module"},
367
- {MRB_TT_OBJECT, "Object"},
368
- {MRB_TT_CLASS, "Class"},
369
- {MRB_TT_ICLASS, "iClass"}, /* internal use: mixed-in module holder */
370
- {MRB_TT_SCLASS, "SClass"},
371
- {MRB_TT_PROC, "Proc"},
372
- #ifndef MRB_WITHOUT_FLOAT
373
- {MRB_TT_FLOAT, "Float"},
374
- #endif
375
- {MRB_TT_ARRAY, "Array"},
376
- {MRB_TT_HASH, "Hash"},
377
- {MRB_TT_STRING, "String"},
378
- {MRB_TT_RANGE, "Range"},
379
- /* {MRB_TT_BIGNUM, "Bignum"}, */
380
- {MRB_TT_DATA, "Data"}, /* internal use: wrapped C pointers */
381
- /* {MRB_TT_VARMAP, "Varmap"}, */ /* internal use: dynamic variables */
382
- /* {MRB_TT_NODE, "Node"}, */ /* internal use: syntax tree node */
383
- /* {MRB_TT_UNDEF, "undef"}, */ /* internal use: #undef; should not happen */
384
- {MRB_TT_MAXDEFINE, 0}
385
- };
386
-
387
399
  MRB_API void
388
400
  mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
389
401
  {
390
- const struct types *type = builtin_types;
391
- enum mrb_vtype xt;
392
-
393
- xt = mrb_type(x);
394
- if ((xt != t) || (xt == MRB_TT_DATA) || (xt == MRB_TT_ISTRUCT)) {
395
- while (type->type < MRB_TT_MAXDEFINE) {
396
- if (type->type == t) {
397
- const char *etype;
398
-
399
- if (mrb_nil_p(x)) {
400
- etype = "nil";
401
- }
402
- else if (mrb_fixnum_p(x)) {
403
- etype = "Fixnum";
404
- }
405
- else if (mrb_symbol_p(x)) {
406
- etype = "Symbol";
407
- }
408
- else if (mrb_immediate_p(x)) {
409
- etype = RSTRING_PTR(mrb_obj_as_string(mrb, x));
410
- }
411
- else {
412
- etype = mrb_obj_classname(mrb, x);
413
- }
414
- mrb_raisef(mrb, E_TYPE_ERROR, "wrong argument type %s (expected %s)",
415
- etype, type->name);
416
- }
417
- type++;
418
- }
419
- mrb_raisef(mrb, E_TYPE_ERROR, "unknown type %d (%d given)", t, mrb_type(x));
402
+ enum mrb_vtype xt = mrb_type(x);
403
+ const char *tname, *ename;
404
+
405
+ if (t == xt) return;
406
+
407
+ tname = type_name(t);
408
+ if (mrb_nil_p(x)) {
409
+ ename = "nil";
410
+ }
411
+ else if (mrb_integer_p(x)) {
412
+ ename = "Fixnum";
413
+ }
414
+ else if (mrb_symbol_p(x)) {
415
+ ename = "Symbol";
416
+ }
417
+ else if (mrb_immediate_p(x)) {
418
+ ename = RSTRING_PTR(mrb_obj_as_string(mrb, x));
419
+ }
420
+ else {
421
+ ename = mrb_obj_classname(mrb, x);
422
+ }
423
+ if (tname) {
424
+ mrb_raisef(mrb, E_TYPE_ERROR, "wrong argument type %s (expected %s)",
425
+ ename, tname);
420
426
  }
427
+ mrb_raisef(mrb, E_TYPE_ERROR, "unknown type %d (%s given)", t, ename);
421
428
  }
422
429
 
423
430
  /* 15.3.1.3.46 */
@@ -503,8 +510,8 @@ MRB_API mrb_value
503
510
  mrb_to_int(mrb_state *mrb, mrb_value val)
504
511
  {
505
512
 
506
- if (!mrb_fixnum_p(val)) {
507
- #ifndef MRB_WITHOUT_FLOAT
513
+ if (!mrb_integer_p(val)) {
514
+ #ifndef MRB_NO_FLOAT
508
515
  if (mrb_float_p(val)) {
509
516
  return mrb_flo_to_fixnum(mrb, val);
510
517
  }
@@ -524,13 +531,13 @@ mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base)
524
531
  mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Integer");
525
532
  }
526
533
  switch (mrb_type(val)) {
527
- #ifndef MRB_WITHOUT_FLOAT
534
+ #ifndef MRB_NO_FLOAT
528
535
  case MRB_TT_FLOAT:
529
536
  if (base != 0) goto arg_error;
530
537
  return mrb_flo_to_fixnum(mrb, val);
531
538
  #endif
532
539
 
533
- case MRB_TT_FIXNUM:
540
+ case MRB_TT_INTEGER:
534
541
  if (base != 0) goto arg_error;
535
542
  return val;
536
543
 
@@ -560,7 +567,7 @@ mrb_Integer(mrb_state *mrb, mrb_value val)
560
567
  return mrb_convert_to_integer(mrb, val, 0);
561
568
  }
562
569
 
563
- #ifndef MRB_WITHOUT_FLOAT
570
+ #ifndef MRB_NO_FLOAT
564
571
  MRB_API mrb_value
565
572
  mrb_Float(mrb_state *mrb, mrb_value val)
566
573
  {
@@ -568,8 +575,8 @@ mrb_Float(mrb_state *mrb, mrb_value val)
568
575
  mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Float");
569
576
  }
570
577
  switch (mrb_type(val)) {
571
- case MRB_TT_FIXNUM:
572
- return mrb_float_value(mrb, (mrb_float)mrb_fixnum(val));
578
+ case MRB_TT_INTEGER:
579
+ return mrb_float_value(mrb, (mrb_float)mrb_integer(val));
573
580
 
574
581
  case MRB_TT_FLOAT:
575
582
  return val;
@@ -578,7 +585,7 @@ mrb_Float(mrb_state *mrb, mrb_value val)
578
585
  return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
579
586
 
580
587
  default:
581
- return mrb_convert_type(mrb, val, MRB_TT_FLOAT, "Float", "to_f");
588
+ return mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
582
589
  }
583
590
  }
584
591
  #endif
@@ -647,12 +654,12 @@ mrb_check_hash_type(mrb_state *mrb, mrb_value hash)
647
654
  MRB_API mrb_value
648
655
  mrb_inspect(mrb_state *mrb, mrb_value obj)
649
656
  {
650
- return mrb_obj_as_string(mrb, mrb_funcall(mrb, obj, "inspect", 0));
657
+ return mrb_obj_as_string(mrb, mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0));
651
658
  }
652
659
 
653
660
  MRB_API mrb_bool
654
661
  mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
655
662
  {
656
663
  if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
657
- return mrb_test(mrb_funcall(mrb, obj1, "eql?", 1, obj2));
664
+ return mrb_test(mrb_funcall_id(mrb, obj1, MRB_SYM_Q(eql), 1, obj2));
658
665
  }
@@ -8,9 +8,10 @@
8
8
  #include <mruby/string.h>
9
9
  #include <mruby/variable.h>
10
10
  #include <mruby/error.h>
11
+ #include <mruby/presym.h>
11
12
  #include <string.h>
12
13
 
13
- #ifndef MRB_DISABLE_STDIO
14
+ #ifndef MRB_NO_STDIO
14
15
  static void
15
16
  printcstr(const char *str, size_t len, FILE *stream)
16
17
  {
@@ -60,11 +61,11 @@ mrb_print_error(mrb_state *mrb)
60
61
  MRB_API void
61
62
  mrb_show_version(mrb_state *mrb)
62
63
  {
63
- printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_DESCRIPTION")), stdout);
64
+ printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), MRB_SYM(MRUBY_DESCRIPTION)), stdout);
64
65
  }
65
66
 
66
67
  MRB_API void
67
68
  mrb_show_copyright(mrb_state *mrb)
68
69
  {
69
- printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_COPYRIGHT")), stdout);
70
+ printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), MRB_SYM(MRUBY_COPYRIGHT)), stdout);
70
71
  }
@@ -9,13 +9,32 @@
9
9
  #include <mruby/proc.h>
10
10
  #include <mruby/opcode.h>
11
11
  #include <mruby/data.h>
12
+ #include <mruby/presym.h>
12
13
 
13
14
  static const mrb_code call_iseq[] = {
14
15
  OP_CALL,
15
16
  };
16
17
 
18
+ static const mrb_irep call_irep = {
19
+ 0, /* nlocals */
20
+ 2, /* nregs */
21
+ 0, /* clen */
22
+ MRB_ISEQ_NO_FREE | MRB_IREP_NO_FREE, /* flags */
23
+ call_iseq, /* iseq */
24
+ NULL, /* pool */
25
+ NULL, /* syms */
26
+ NULL, /* reps */
27
+ NULL, /* lv */
28
+ NULL, /* debug_info */
29
+ 1, /* ilen */
30
+ 0, /* plen */
31
+ 0, /* slen */
32
+ 1, /* rlen */
33
+ 0, /* refcnt */
34
+ };
35
+
17
36
  struct RProc*
18
- mrb_proc_new(mrb_state *mrb, mrb_irep *irep)
37
+ mrb_proc_new(mrb_state *mrb, const mrb_irep *irep)
19
38
  {
20
39
  struct RProc *p;
21
40
  mrb_callinfo *ci = mrb->c->ci;
@@ -28,33 +47,34 @@ mrb_proc_new(mrb_state *mrb, mrb_irep *irep)
28
47
  tc = MRB_PROC_TARGET_CLASS(ci->proc);
29
48
  }
30
49
  if (tc == NULL) {
31
- tc = ci->target_class;
50
+ tc = mrb_vm_ci_target_class(ci);
32
51
  }
33
52
  p->upper = ci->proc;
34
53
  p->e.target_class = tc;
35
54
  }
36
55
  p->body.irep = irep;
37
- mrb_irep_incref(mrb, irep);
56
+ if (irep) {
57
+ mrb_irep_incref(mrb, (mrb_irep*)irep);
58
+ }
38
59
 
39
60
  return p;
40
61
  }
41
62
 
42
- static struct REnv*
43
- env_new(mrb_state *mrb, mrb_int nlocals)
63
+ struct REnv*
64
+ mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks, mrb_value *stack, struct RClass *tc)
44
65
  {
45
66
  struct REnv *e;
46
- mrb_callinfo *ci = mrb->c->ci;
47
- int bidx;
67
+ mrb_int bidx;
48
68
 
49
- e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, NULL);
50
- MRB_ENV_SET_LEN(e, nlocals);
69
+ e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, tc);
70
+ MRB_ENV_SET_LEN(e, nstacks);
51
71
  bidx = ci->argc;
52
- if (ci->argc < 0) bidx = 2;
72
+ if (bidx < 0) bidx = 2;
53
73
  else bidx += 1;
54
74
  MRB_ENV_SET_BIDX(e, bidx);
55
75
  e->mid = ci->mid;
56
- e->stack = mrb->c->stack;
57
- e->cxt = mrb->c;
76
+ e->stack = stack;
77
+ e->cxt = c;
58
78
 
59
79
  return e;
60
80
  }
@@ -63,21 +83,17 @@ static void
63
83
  closure_setup(mrb_state *mrb, struct RProc *p)
64
84
  {
65
85
  mrb_callinfo *ci = mrb->c->ci;
66
- struct RProc *up = p->upper;
86
+ const struct RProc *up = p->upper;
67
87
  struct REnv *e = NULL;
68
88
 
69
- if (ci && ci->env) {
70
- e = ci->env;
89
+ if (ci && (e = mrb_vm_ci_env(ci)) != NULL) {
90
+ /* do nothing, because e is assigned already */
71
91
  }
72
92
  else if (up) {
73
93
  struct RClass *tc = MRB_PROC_TARGET_CLASS(p);
74
94
 
75
- e = env_new(mrb, up->body.irep->nlocals);
76
- ci->env = e;
77
- if (tc) {
78
- e->c = tc;
79
- mrb_field_write_barrier(mrb, (struct RBasic*)e, (struct RBasic*)tc);
80
- }
95
+ e = mrb_env_new(mrb, mrb->c, ci, up->body.irep->nlocals, ci->stack, tc);
96
+ ci->u.env = e;
81
97
  if (MRB_PROC_ENV_P(up) && MRB_PROC_ENV(up)->cxt == NULL) {
82
98
  e->mid = MRB_PROC_ENV(up)->mid;
83
99
  }
@@ -90,7 +106,7 @@ closure_setup(mrb_state *mrb, struct RProc *p)
90
106
  }
91
107
 
92
108
  struct RProc*
93
- mrb_closure_new(mrb_state *mrb, mrb_irep *irep)
109
+ mrb_closure_new(mrb_state *mrb, const mrb_irep *irep)
94
110
  {
95
111
  struct RProc *p = mrb_proc_new(mrb, irep);
96
112
 
@@ -119,15 +135,11 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const
119
135
  struct REnv *e;
120
136
  int i;
121
137
 
122
- p->e.env = e = env_new(mrb, argc);
138
+ p->e.env = e = mrb_env_new(mrb, mrb->c, mrb->c->ci, 0, NULL, NULL);
123
139
  p->flags |= MRB_PROC_ENVSET;
124
140
  mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)e);
125
141
  MRB_ENV_CLOSE(e);
126
142
 
127
- /* NOTE: Prevents keeping invalid addresses when NoMemoryError is raised from `mrb_malloc()`. */
128
- e->stack = NULL;
129
- MRB_ENV_SET_LEN(e, 0);
130
-
131
143
  e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc);
132
144
  MRB_ENV_SET_LEN(e, argc);
133
145
 
@@ -153,7 +165,7 @@ mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals)
153
165
  MRB_API mrb_value
154
166
  mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx)
155
167
  {
156
- struct RProc *p = mrb->c->ci->proc;
168
+ const struct RProc *p = mrb->c->ci->proc;
157
169
  struct REnv *e;
158
170
 
159
171
  if (!p || !MRB_PROC_CFUNC_P(p)) {
@@ -181,7 +193,7 @@ mrb_proc_copy(struct RProc *a, struct RProc *b)
181
193
  a->flags = b->flags;
182
194
  a->body = b->body;
183
195
  if (!MRB_PROC_CFUNC_P(a) && a->body.irep) {
184
- a->body.irep->refcnt++;
196
+ mrb_irep_incref(NULL, (mrb_irep*)a->body.irep);
185
197
  }
186
198
  a->upper = b->upper;
187
199
  a->e.env = b->e.env;
@@ -200,9 +212,9 @@ mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
200
212
  p = (struct RProc *)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb_class_ptr(proc_class));
201
213
  mrb_proc_copy(p, mrb_proc_ptr(blk));
202
214
  proc = mrb_obj_value(p);
203
- mrb_funcall_with_block(mrb, proc, mrb_intern_lit(mrb, "initialize"), 0, NULL, proc);
215
+ mrb_funcall_with_block(mrb, proc, MRB_SYM(initialize), 0, NULL, proc);
204
216
  if (!MRB_PROC_STRICT_P(p) &&
205
- mrb->c->ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb->c->ci[-1].env) {
217
+ mrb->c->ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb->c->ci[-1].u.env) {
206
218
  p->flags |= MRB_PROC_ORPHAN;
207
219
  }
208
220
  return proc;
@@ -224,7 +236,7 @@ mrb_proc_init_copy(mrb_state *mrb, mrb_value self)
224
236
  static mrb_value
225
237
  proc_arity(mrb_state *mrb, mrb_value self)
226
238
  {
227
- return mrb_fixnum_value(mrb_proc_arity(mrb_proc_ptr(self)));
239
+ return mrb_int_value(mrb, mrb_proc_arity(mrb_proc_ptr(self)));
228
240
  }
229
241
 
230
242
  /* 15.3.1.2.6 */
@@ -262,7 +274,7 @@ proc_lambda(mrb_state *mrb, mrb_value self)
262
274
  mrb_int
263
275
  mrb_proc_arity(const struct RProc *p)
264
276
  {
265
- struct mrb_irep *irep;
277
+ const mrb_irep *irep;
266
278
  const mrb_code *pc;
267
279
  mrb_aspec aspec;
268
280
  int ma, op, ra, pa, arity;
@@ -293,40 +305,20 @@ mrb_proc_arity(const struct RProc *p)
293
305
  return arity;
294
306
  }
295
307
 
296
- static void
297
- tempirep_free(mrb_state *mrb, void *p)
298
- {
299
- if (p) mrb_irep_free(mrb, (mrb_irep *)p);
300
- }
301
-
302
- static const mrb_data_type tempirep_type = { "temporary irep", tempirep_free };
303
-
304
308
  void
305
309
  mrb_init_proc(mrb_state *mrb)
306
310
  {
307
311
  struct RProc *p;
308
312
  mrb_method_t m;
309
- struct RData *irep_obj = mrb_data_object_alloc(mrb, mrb->object_class, NULL, &tempirep_type);
310
- mrb_irep *call_irep;
311
- static const mrb_irep mrb_irep_zero = { 0 };
312
-
313
- call_irep = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
314
- irep_obj->data = call_irep;
315
- *call_irep = mrb_irep_zero;
316
- call_irep->flags = MRB_ISEQ_NO_FREE;
317
- call_irep->iseq = call_iseq;
318
- call_irep->ilen = 1;
319
- call_irep->nregs = 2; /* receiver and block */
320
313
 
321
314
  mrb_define_class_method(mrb, mrb->proc_class, "new", mrb_proc_s_new, MRB_ARGS_NONE()|MRB_ARGS_BLOCK());
322
315
  mrb_define_method(mrb, mrb->proc_class, "initialize_copy", mrb_proc_init_copy, MRB_ARGS_REQ(1));
323
316
  mrb_define_method(mrb, mrb->proc_class, "arity", proc_arity, MRB_ARGS_NONE());
324
317
 
325
- p = mrb_proc_new(mrb, call_irep);
326
- irep_obj->data = NULL;
318
+ p = mrb_proc_new(mrb, &call_irep);
327
319
  MRB_METHOD_FROM_PROC(m, p);
328
- mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "call"), m);
329
- mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "[]"), m);
320
+ mrb_define_method_raw(mrb, mrb->proc_class, MRB_SYM(call), m);
321
+ mrb_define_method_raw(mrb, mrb->proc_class, MRB_OPSYM(aref), m);
330
322
 
331
323
  mrb_define_class_method(mrb, mrb->kernel_module, "lambda", proc_lambda, MRB_ARGS_NONE()|MRB_ARGS_BLOCK()); /* 15.3.1.2.6 */
332
324
  mrb_define_method(mrb, mrb->kernel_module, "lambda", proc_lambda, MRB_ARGS_NONE()|MRB_ARGS_BLOCK()); /* 15.3.1.3.27 */