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/range.h>
10
10
  #include <mruby/string.h>
11
11
  #include <mruby/array.h>
12
+ #include <mruby/presym.h>
12
13
 
13
14
  #define RANGE_INITIALIZED_MASK 1
14
15
  #define RANGE_INITIALIZED(p) ((p)->flags |= RANGE_INITIALIZED_MASK)
@@ -23,15 +24,17 @@ r_check(mrb_state *mrb, mrb_value a, mrb_value b)
23
24
 
24
25
  ta = mrb_type(a);
25
26
  tb = mrb_type(b);
26
- #ifdef MRB_WITHOUT_FLOAT
27
- if (ta == MRB_TT_FIXNUM && tb == MRB_TT_FIXNUM ) {
27
+ #ifdef MRB_NO_FLOAT
28
+ if (ta == MRB_TT_INTEGER && tb == MRB_TT_INTEGER ) {
28
29
  #else
29
- if ((ta == MRB_TT_FIXNUM || ta == MRB_TT_FLOAT) &&
30
- (tb == MRB_TT_FIXNUM || tb == MRB_TT_FLOAT)) {
30
+ if ((ta == MRB_TT_INTEGER || ta == MRB_TT_FLOAT) &&
31
+ (tb == MRB_TT_INTEGER || tb == MRB_TT_FLOAT)) {
31
32
  #endif
32
33
  return;
33
34
  }
34
35
 
36
+ if (mrb_nil_p(a) || mrb_nil_p(b)) return;
37
+
35
38
  n = mrb_cmp(mrb, a, b);
36
39
  if (n == -2) { /* can not be compared */
37
40
  mrb_raise(mrb, E_ARGUMENT_ERROR, "bad value for range");
@@ -78,7 +81,7 @@ range_ptr_init(mrb_state *mrb, struct RRange *r, mrb_value beg, mrb_value end, m
78
81
  if (r) {
79
82
  if (RANGE_INITIALIZED_P(r)) {
80
83
  /* Ranges are immutable, so that they should be initialized only once. */
81
- mrb_name_error(mrb, mrb_intern_lit(mrb, "initialize"), "'initialize' called twice");
84
+ mrb_name_error(mrb, MRB_SYM(initialize), "'initialize' called twice");
82
85
  }
83
86
  else {
84
87
  range_ptr_alloc_edges(mrb, r);
@@ -161,6 +164,7 @@ range_initialize(mrb_state *mrb, mrb_value range)
161
164
 
162
165
  mrb_get_args(mrb, "oo|b", &beg, &end, &exclusive);
163
166
  range_ptr_replace(mrb, mrb_range_raw_ptr(range), beg, end, exclusive);
167
+ mrb_obj_freeze(mrb, range);
164
168
  return range;
165
169
  }
166
170
 
@@ -212,15 +216,25 @@ range_include(mrb_state *mrb, mrb_value range)
212
216
  mrb_value val = mrb_get_arg1(mrb);
213
217
  struct RRange *r = mrb_range_ptr(mrb, range);
214
218
  mrb_value beg, end;
215
- mrb_bool include_p;
216
219
 
217
220
  beg = RANGE_BEG(r);
218
221
  end = RANGE_END(r);
219
- include_p = r_le(mrb, beg, val) && /* beg <= val */
220
- (RANGE_EXCL(r) ? r_gt(mrb, end, val) /* end > val */
221
- : r_ge(mrb, end, val)); /* end >= val */
222
-
223
- return mrb_bool_value(include_p);
222
+ if (mrb_nil_p(beg)) {
223
+ if (RANGE_EXCL(r) ? r_gt(mrb, end, val) /* end > val */
224
+ : r_ge(mrb, end, val)) { /* end >= val */
225
+ return mrb_true_value();
226
+ }
227
+ }
228
+ else if (r_le(mrb, beg, val)) { /* beg <= val */
229
+ if (mrb_nil_p(end)) {
230
+ return mrb_true_value();
231
+ }
232
+ if (RANGE_EXCL(r) ? r_gt(mrb, end, val) /* end > val */
233
+ : r_ge(mrb, end, val)) { /* end >= val */
234
+ return mrb_true_value();
235
+ }
236
+ }
237
+ return mrb_false_value();
224
238
  }
225
239
 
226
240
  /* 15.2.14.4.12(x) */
@@ -257,14 +271,21 @@ range_to_s(mrb_state *mrb, mrb_value range)
257
271
  static mrb_value
258
272
  range_inspect(mrb_state *mrb, mrb_value range)
259
273
  {
260
- mrb_value str, str2;
274
+ mrb_value str;
261
275
  struct RRange *r = mrb_range_ptr(mrb, range);
262
276
 
263
- str = mrb_inspect(mrb, RANGE_BEG(r));
264
- str2 = mrb_inspect(mrb, RANGE_END(r));
265
- str = mrb_str_dup(mrb, str);
266
- mrb_str_cat(mrb, str, "...", RANGE_EXCL(r) ? 3 : 2);
267
- mrb_str_cat_str(mrb, str, str2);
277
+ if (!mrb_nil_p(RANGE_BEG(r))) {
278
+ str = mrb_inspect(mrb, RANGE_BEG(r));
279
+ str = mrb_str_dup(mrb, str);
280
+ mrb_str_cat(mrb, str, "...", RANGE_EXCL(r) ? 3 : 2);
281
+ }
282
+ else {
283
+ str = mrb_str_new(mrb, "...", RANGE_EXCL(r) ? 3 : 2);
284
+ }
285
+ if (!mrb_nil_p(RANGE_END(r))) {
286
+ mrb_value str2 = mrb_inspect(mrb, RANGE_END(r));
287
+ mrb_str_cat_str(mrb, str, str2);
288
+ }
268
289
 
269
290
  return str;
270
291
  }
@@ -316,6 +337,7 @@ range_initialize_copy(mrb_state *mrb, mrb_value copy)
316
337
 
317
338
  r = mrb_range_ptr(mrb, src);
318
339
  range_ptr_replace(mrb, mrb_range_raw_ptr(copy), RANGE_BEG(r), RANGE_END(r), RANGE_EXCL(r));
340
+ mrb_obj_freeze(mrb, copy);
319
341
 
320
342
  return copy;
321
343
  }
@@ -328,8 +350,8 @@ mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, con
328
350
  result = mrb_ary_new(mrb);
329
351
 
330
352
  for (i = 0; i < argc; ++i) {
331
- if (mrb_fixnum_p(argv[i])) {
332
- mrb_ary_push(mrb, result, func(mrb, obj, mrb_fixnum(argv[i])));
353
+ if (mrb_integer_p(argv[i])) {
354
+ mrb_ary_push(mrb, result, func(mrb, obj, mrb_integer(argv[i])));
333
355
  }
334
356
  else if (mrb_range_beg_len(mrb, argv[i], &beg, &len, olen, FALSE) == MRB_RANGE_OK) {
335
357
  mrb_int const end = olen < beg + len ? olen : beg + len;
@@ -381,13 +403,15 @@ MRB_API enum mrb_range_beg_len
381
403
  mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc)
382
404
  {
383
405
  mrb_int beg, end;
406
+ mrb_bool excl;
384
407
  struct RRange *r;
385
408
 
386
409
  if (!mrb_range_p(range)) return MRB_RANGE_TYPE_MISMATCH;
387
410
  r = mrb_range_ptr(mrb, range);
388
411
 
389
412
  beg = mrb_int(mrb, RANGE_BEG(r));
390
- end = mrb_int(mrb, RANGE_END(r));
413
+ end = mrb_nil_p(RANGE_END(r)) ? -1 : mrb_int(mrb, RANGE_END(r));
414
+ excl = mrb_nil_p(RANGE_END(r)) ? 0 : RANGE_EXCL(r);
391
415
 
392
416
  if (beg < 0) {
393
417
  beg += len;
@@ -400,7 +424,7 @@ mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp,
400
424
  }
401
425
 
402
426
  if (end < 0) end += len;
403
- if (!RANGE_EXCL(r) && (!trunc || end < len)) end++; /* include end point */
427
+ if (!excl && (!trunc || end < len)) end++; /* include end point */
404
428
  len = end - beg;
405
429
  if (len < 0) len = 0;
406
430
 
@@ -77,11 +77,13 @@ mrb_open(void)
77
77
  return mrb;
78
78
  }
79
79
 
80
+ #ifndef MRB_NO_GEMS
80
81
  static void
81
82
  init_mrbgems(mrb_state *mrb, void *opaque)
82
83
  {
83
84
  mrb_init_mrbgems(mrb);
84
85
  }
86
+ #endif
85
87
 
86
88
  MRB_API mrb_state*
87
89
  mrb_open_allocf(mrb_allocf f, void *ud)
@@ -92,7 +94,7 @@ mrb_open_allocf(mrb_allocf f, void *ud)
92
94
  return NULL;
93
95
  }
94
96
 
95
- #ifndef DISABLE_GEMS
97
+ #ifndef MRB_NO_GEMS
96
98
  if (mrb_core_init_protect(mrb, init_mrbgems, NULL)) {
97
99
  mrb_close(mrb);
98
100
  return NULL;
@@ -107,12 +109,14 @@ void mrb_free_symtbl(mrb_state *mrb);
107
109
  void
108
110
  mrb_irep_incref(mrb_state *mrb, mrb_irep *irep)
109
111
  {
112
+ if (irep->flags & MRB_IREP_NO_FREE) return;
110
113
  irep->refcnt++;
111
114
  }
112
115
 
113
116
  void
114
117
  mrb_irep_decref(mrb_state *mrb, mrb_irep *irep)
115
118
  {
119
+ if (irep->flags & MRB_IREP_NO_FREE) return;
116
120
  irep->refcnt--;
117
121
  if (irep->refcnt == 0) {
118
122
  mrb_irep_free(mrb, irep);
@@ -122,12 +126,14 @@ mrb_irep_decref(mrb_state *mrb, mrb_irep *irep)
122
126
  void
123
127
  mrb_irep_cutref(mrb_state *mrb, mrb_irep *irep)
124
128
  {
125
- mrb_irep *tmp;
129
+ mrb_irep **reps;
126
130
  int i;
127
131
 
132
+ if (irep->flags & MRB_IREP_NO_FREE) return;
133
+ reps = (mrb_irep**)irep->reps;
128
134
  for (i=0; i<irep->rlen; i++) {
129
- tmp = irep->reps[i];
130
- irep->reps[i] = NULL;
135
+ mrb_irep *tmp = reps[i];
136
+ reps[i] = NULL;
131
137
  if (tmp) mrb_irep_decref(mrb, tmp);
132
138
  }
133
139
  }
@@ -137,59 +143,46 @@ mrb_irep_free(mrb_state *mrb, mrb_irep *irep)
137
143
  {
138
144
  int i;
139
145
 
146
+ if (irep->flags & MRB_IREP_NO_FREE) return;
140
147
  if (!(irep->flags & MRB_ISEQ_NO_FREE))
141
148
  mrb_free(mrb, (void*)irep->iseq);
142
- if (irep->pool) for (i=0; i<irep->plen; i++) {
143
- if (mrb_string_p(irep->pool[i])) {
144
- mrb_gc_free_str(mrb, RSTRING(irep->pool[i]));
145
- mrb_free(mrb, mrb_obj_ptr(irep->pool[i]));
146
- }
147
- #if defined(MRB_WORD_BOXING) && !defined(MRB_WITHOUT_FLOAT)
148
- else if (mrb_float_p(irep->pool[i])) {
149
- mrb_free(mrb, mrb_obj_ptr(irep->pool[i]));
149
+ if (irep->pool) {
150
+ for (i=0; i<irep->plen; i++) {
151
+ if ((irep->pool[i].tt & 3) == IREP_TT_STR) {
152
+ mrb_free(mrb, (void*)irep->pool[i].u.str);
153
+ }
150
154
  }
151
- #endif
155
+ mrb_free(mrb, (void*)irep->pool);
152
156
  }
153
- mrb_free(mrb, irep->pool);
154
- mrb_free(mrb, irep->syms);
157
+ mrb_free(mrb, (void*)irep->syms);
155
158
  if (irep->reps) {
156
159
  for (i=0; i<irep->rlen; i++) {
157
160
  if (irep->reps[i])
158
- mrb_irep_decref(mrb, irep->reps[i]);
161
+ mrb_irep_decref(mrb, (mrb_irep*)irep->reps[i]);
159
162
  }
163
+ mrb_free(mrb, (void*)irep->reps);
160
164
  }
161
- mrb_free(mrb, irep->reps);
162
- mrb_free(mrb, irep->lv);
165
+ mrb_free(mrb, (void*)irep->lv);
163
166
  mrb_debug_info_free(mrb, irep->debug_info);
164
167
  mrb_free(mrb, irep);
165
168
  }
166
169
 
167
- void mrb_free_backtrace(mrb_state *mrb);
168
-
169
170
  MRB_API void
170
171
  mrb_free_context(mrb_state *mrb, struct mrb_context *c)
171
172
  {
172
173
  if (!c) return;
173
174
  mrb_free(mrb, c->stbase);
174
175
  mrb_free(mrb, c->cibase);
175
- mrb_free(mrb, c->rescue);
176
- mrb_free(mrb, c->ensure);
177
176
  mrb_free(mrb, c);
178
177
  }
179
178
 
180
- MRB_API void
179
+ int mrb_protect_atexit(mrb_state *mrb);
180
+
181
+ MRB_API void
181
182
  mrb_close(mrb_state *mrb)
182
183
  {
183
184
  if (!mrb) return;
184
- if (mrb->atexit_stack_len > 0) {
185
- mrb_int i;
186
- for (i = mrb->atexit_stack_len; i > 0; --i) {
187
- mrb->atexit_stack[i - 1](mrb);
188
- }
189
- #ifndef MRB_FIXED_STATE_ATEXIT_STACK
190
- mrb_free(mrb, mrb->atexit_stack);
191
- #endif
192
- }
185
+ mrb_protect_atexit(mrb);
193
186
 
194
187
  /* free */
195
188
  mrb_gc_destroy(mrb, &mrb->gc);
@@ -8,7 +8,7 @@
8
8
  # define _CRT_NONSTDC_NO_DEPRECATE
9
9
  #endif
10
10
 
11
- #ifndef MRB_WITHOUT_FLOAT
11
+ #ifndef MRB_NO_FLOAT
12
12
  #include <float.h>
13
13
  #include <math.h>
14
14
  #endif
@@ -22,6 +22,7 @@
22
22
  #include <mruby/range.h>
23
23
  #include <mruby/string.h>
24
24
  #include <mruby/numeric.h>
25
+ #include <mruby/presym.h>
25
26
 
26
27
  typedef struct mrb_shared_string {
27
28
  int refcnt;
@@ -175,19 +176,6 @@ mrb_str_new_capa(mrb_state *mrb, size_t capa)
175
176
  return mrb_obj_value(s);
176
177
  }
177
178
 
178
- #ifndef MRB_STR_BUF_MIN_SIZE
179
- # define MRB_STR_BUF_MIN_SIZE 128
180
- #endif
181
-
182
- MRB_API mrb_value
183
- mrb_str_buf_new(mrb_state *mrb, size_t capa)
184
- {
185
- if (capa < MRB_STR_BUF_MIN_SIZE) {
186
- capa = MRB_STR_BUF_MIN_SIZE;
187
- }
188
- return mrb_str_new_capa(mrb, capa);
189
- }
190
-
191
179
  static void
192
180
  resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
193
181
  {
@@ -297,10 +285,12 @@ static const char utf8len_codepage[256] =
297
285
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
298
286
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
299
287
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
300
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
288
+ 1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
301
289
  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,
302
290
  };
303
291
 
292
+ #define utf8_islead(c) ((unsigned char)((c)&0xc0) != 0x80)
293
+
304
294
  mrb_int
305
295
  mrb_utf8len(const char* p, const char* e)
306
296
  {
@@ -312,7 +302,7 @@ mrb_utf8len(const char* p, const char* e)
312
302
  if (len == 1) return 1;
313
303
  if (len > e - p) return 1;
314
304
  for (i = 1; i < len; ++i)
315
- if ((p[i] & 0xc0) != 0x80)
305
+ if (utf8_islead(p[i]))
316
306
  return 1;
317
307
  return len;
318
308
  }
@@ -320,15 +310,15 @@ mrb_utf8len(const char* p, const char* e)
320
310
  mrb_int
321
311
  mrb_utf8_strlen(const char *str, mrb_int byte_len)
322
312
  {
323
- mrb_int total = 0;
313
+ mrb_int len = 0;
324
314
  const char *p = str;
325
315
  const char *e = p + byte_len;
326
316
 
327
317
  while (p < e) {
328
318
  p += mrb_utf8len(p, e);
329
- total++;
319
+ len++;
330
320
  }
331
- return total;
321
+ return len;
332
322
  }
333
323
 
334
324
  static mrb_int
@@ -583,9 +573,6 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s)
583
573
  else if (RSTR_FSHARED_P(orig)) {
584
574
  str_init_fshared(orig, s, orig->as.heap.aux.fshared);
585
575
  }
586
- else if (mrb_frozen_p(orig) && !RSTR_POOL_P(orig)) {
587
- str_init_fshared(orig, s, orig);
588
- }
589
576
  else {
590
577
  if (orig->as.heap.aux.capa > orig->as.heap.len) {
591
578
  orig->as.heap.ptr = (char *)mrb_realloc(mrb, orig->as.heap.ptr, len+1);
@@ -596,29 +583,6 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s)
596
583
  }
597
584
  }
598
585
 
599
- mrb_value
600
- mrb_str_pool(mrb_state *mrb, const char *p, mrb_int len, mrb_bool nofree)
601
- {
602
- struct RString *s = (struct RString *)mrb_malloc(mrb, sizeof(struct RString));
603
-
604
- s->tt = MRB_TT_STRING;
605
- s->c = mrb->string_class;
606
- s->flags = 0;
607
-
608
- if (RSTR_EMBEDDABLE_P(len)) {
609
- str_init_embed(s, p, len);
610
- }
611
- else if (nofree) {
612
- str_init_nofree(s, p, len);
613
- }
614
- else {
615
- str_init_normal(mrb, s, p, len);
616
- }
617
- RSTR_SET_POOL_FLAG(s);
618
- MRB_SET_FROZEN_FLAG(s);
619
- return mrb_obj_value(s);
620
- }
621
-
622
586
  mrb_value
623
587
  mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
624
588
  {
@@ -898,7 +862,7 @@ mrb_str_to_cstr(mrb_state *mrb, mrb_value str0)
898
862
  MRB_API void
899
863
  mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
900
864
  {
901
- other = mrb_str_to_str(mrb, other);
865
+ other = mrb_obj_as_string(mrb, other);
902
866
  mrb_str_cat_str(mrb, self, other);
903
867
  }
904
868
 
@@ -1111,29 +1075,11 @@ mrb_str_equal_m(mrb_state *mrb, mrb_value str1)
1111
1075
  }
1112
1076
  /* ---------------------------------- */
1113
1077
 
1114
- MRB_API mrb_value
1115
- mrb_str_to_str(mrb_state *mrb, mrb_value str)
1116
- {
1117
- switch (mrb_type(str)) {
1118
- case MRB_TT_STRING:
1119
- return str;
1120
- case MRB_TT_SYMBOL:
1121
- return mrb_sym_str(mrb, mrb_symbol(str));
1122
- case MRB_TT_FIXNUM:
1123
- return mrb_fixnum_to_str(mrb, str, 10);
1124
- case MRB_TT_CLASS:
1125
- case MRB_TT_MODULE:
1126
- return mrb_mod_to_s(mrb, str);
1127
- default:
1128
- return mrb_convert_type(mrb, str, MRB_TT_STRING, "String", "to_s");
1129
- }
1130
- }
1131
-
1132
1078
  /* obslete: use RSTRING_PTR() */
1133
1079
  MRB_API const char*
1134
1080
  mrb_string_value_ptr(mrb_state *mrb, mrb_value str)
1135
1081
  {
1136
- str = mrb_str_to_str(mrb, str);
1082
+ str = mrb_obj_as_string(mrb, str);
1137
1083
  return RSTRING_PTR(str);
1138
1084
  }
1139
1085
 
@@ -1179,8 +1125,8 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
1179
1125
  }
1180
1126
  else {
1181
1127
  switch (mrb_type(indx)) {
1182
- case MRB_TT_FIXNUM:
1183
- *beg = mrb_fixnum(indx);
1128
+ case MRB_TT_INTEGER:
1129
+ *beg = mrb_integer(indx);
1184
1130
  *len = 1;
1185
1131
  return STR_CHAR_RANGE;
1186
1132
 
@@ -1195,8 +1141,8 @@ str_convert_range(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen,
1195
1141
 
1196
1142
  default:
1197
1143
  indx = mrb_to_int(mrb, indx);
1198
- if (mrb_fixnum_p(indx)) {
1199
- *beg = mrb_fixnum(indx);
1144
+ if (mrb_integer_p(indx)) {
1145
+ *beg = mrb_integer(indx);
1200
1146
  *len = 1;
1201
1147
  return STR_CHAR_RANGE;
1202
1148
  }
@@ -1211,7 +1157,7 @@ range_arg:
1211
1157
  break;
1212
1158
  }
1213
1159
 
1214
- mrb_raise(mrb, E_TYPE_ERROR, "can't convert to Fixnum");
1160
+ mrb_raise(mrb, E_TYPE_ERROR, "can't convert to Integer");
1215
1161
  }
1216
1162
  }
1217
1163
  return STR_OUT_OF_RANGE;
@@ -1255,8 +1201,8 @@ mrb_str_aref(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen)
1255
1201
  * str.slice(range) => new_str or nil
1256
1202
  * str.slice(other_str) => new_str or nil
1257
1203
  *
1258
- * Element Reference---If passed a single <code>Fixnum</code>, returns the code
1259
- * of the character at that position. If passed two <code>Fixnum</code>
1204
+ * Element Reference---If passed a single <code>Integer</code>, returns the code
1205
+ * of the character at that position. If passed two <code>Integer</code>
1260
1206
  * objects, returns a substring starting at the offset given by the first, and
1261
1207
  * a length given by the second. If given a range, a substring containing
1262
1208
  * characters at offsets given by the range is returned. In all three cases, if
@@ -1314,7 +1260,7 @@ str_replace_partial(mrb_state *mrb, mrb_value src, mrb_int pos, mrb_int end, mrb
1314
1260
  }
1315
1261
 
1316
1262
  replen = (mrb_nil_p(rep) ? 0 : RSTRING_LEN(rep));
1317
- newlen = replen + len - (end - pos);
1263
+ newlen = replen + (len - (end - pos));
1318
1264
 
1319
1265
  if (newlen >= MRB_SSIZE_MAX || newlen < replen /* overflowed */) {
1320
1266
  mrb_raise(mrb, E_RUNTIME_ERROR, "string size too big");
@@ -1809,13 +1755,17 @@ mrb_str_hash(mrb_state *mrb, mrb_value str)
1809
1755
  struct RString *s = mrb_str_ptr(str);
1810
1756
  mrb_int len = RSTR_LEN(s);
1811
1757
  char *p = RSTR_PTR(s);
1812
- uint64_t key = 0;
1758
+ uint32_t hash = 0;
1813
1759
 
1814
- while (len--) {
1815
- key = key*65599 + *p;
1816
- p++;
1760
+ for(int i = 0; i < len; ++i) {
1761
+ hash += p[i];
1762
+ hash += (hash << 10);
1763
+ hash ^= (hash >> 6);
1817
1764
  }
1818
- return (uint32_t)(key + (key>>5));
1765
+ hash += (hash << 3);
1766
+ hash ^= (hash >> 11);
1767
+ hash += (hash << 15);
1768
+ return hash;
1819
1769
  }
1820
1770
 
1821
1771
  /* 15.2.10.5.20 */
@@ -1962,10 +1912,20 @@ mrb_str_intern(mrb_state *mrb, mrb_value self)
1962
1912
  MRB_API mrb_value
1963
1913
  mrb_obj_as_string(mrb_state *mrb, mrb_value obj)
1964
1914
  {
1965
- if (mrb_string_p(obj)) {
1915
+ switch (mrb_type(obj)) {
1916
+ case MRB_TT_STRING:
1966
1917
  return obj;
1918
+ case MRB_TT_SYMBOL:
1919
+ return mrb_sym_str(mrb, mrb_symbol(obj));
1920
+ case MRB_TT_INTEGER:
1921
+ return mrb_fixnum_to_str(mrb, obj, 10);
1922
+ case MRB_TT_SCLASS:
1923
+ case MRB_TT_CLASS:
1924
+ case MRB_TT_MODULE:
1925
+ return mrb_mod_to_s(mrb, obj);
1926
+ default:
1927
+ return mrb_type_convert(mrb, obj, MRB_TT_STRING, MRB_SYM(to_s));
1967
1928
  }
1968
- return mrb_str_to_str(mrb, obj);
1969
1929
  }
1970
1930
 
1971
1931
  MRB_API mrb_value
@@ -2257,13 +2217,13 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
2257
2217
  }
2258
2218
 
2259
2219
  mrb_value
2260
- mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base, int badcheck)
2220
+ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, mrb_int base, int badcheck)
2261
2221
  {
2262
2222
  const char *p = str;
2263
2223
  const char *pend = str + len;
2264
2224
  char sign = 1;
2265
2225
  int c;
2266
- uint64_t n = 0;
2226
+ mrb_int n = 0;
2267
2227
  mrb_int val;
2268
2228
 
2269
2229
  #define conv_digit(c) \
@@ -2390,19 +2350,17 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base,
2390
2350
  if (c < 0 || c >= base) {
2391
2351
  break;
2392
2352
  }
2393
- n *= base;
2394
- n += c;
2395
- if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) {
2396
- #ifndef MRB_WITHOUT_FLOAT
2397
- if (base == 10) {
2398
- return mrb_float_value(mrb, mrb_str_to_dbl(mrb, mrb_str_new(mrb, str, len), badcheck));
2399
- }
2400
- else
2401
- #endif
2402
- {
2403
- mrb_raisef(mrb, E_RANGE_ERROR, "string (%l) too big for integer", str, pend-str);
2353
+ if (mrb_int_mul_overflow(n, base, &n)) goto overflow;
2354
+ if (MRB_INT_MAX - c < n) {
2355
+ if (sign == 0 && MRB_INT_MAX - n == c - 1) {
2356
+ n = MRB_INT_MIN;
2357
+ sign = 1;
2358
+ break;
2404
2359
  }
2360
+ overflow:
2361
+ mrb_raisef(mrb, E_RANGE_ERROR, "string (%l) too big for integer", str, pend-str);
2405
2362
  }
2363
+ n += c;
2406
2364
  }
2407
2365
  val = (mrb_int)n;
2408
2366
  if (badcheck) {
@@ -2412,7 +2370,7 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base,
2412
2370
  if (p<pend) goto bad; /* trailing garbage */
2413
2371
  }
2414
2372
 
2415
- return mrb_fixnum_value(sign ? val : -val);
2373
+ return mrb_int_value(mrb, sign ? val : -val);
2416
2374
  nullbyte:
2417
2375
  mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
2418
2376
  /* not reached */
@@ -2504,7 +2462,7 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
2504
2462
  return mrb_str_to_inum(mrb, self, base, FALSE);
2505
2463
  }
2506
2464
 
2507
- #ifndef MRB_WITHOUT_FLOAT
2465
+ #ifndef MRB_NO_FLOAT
2508
2466
  double
2509
2467
  mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
2510
2468
  {
@@ -2526,8 +2484,8 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
2526
2484
 
2527
2485
  if (!badcheck) return 0.0;
2528
2486
  x = mrb_str_len_to_inum(mrb, p, pend-p, 0, badcheck);
2529
- if (mrb_fixnum_p(x))
2530
- d = (double)mrb_fixnum(x);
2487
+ if (mrb_integer_p(x))
2488
+ d = (double)mrb_integer(x);
2531
2489
  else /* if (mrb_float_p(x)) */
2532
2490
  d = mrb_float(x);
2533
2491
  return d;
@@ -2902,7 +2860,7 @@ mrb_str_byteslice(mrb_state *mrb, mrb_value str)
2902
2860
  }
2903
2861
  }
2904
2862
  else {
2905
- beg = mrb_fixnum(mrb_to_int(mrb, a1));
2863
+ beg = mrb_integer(mrb_to_int(mrb, a1));
2906
2864
  len = 1;
2907
2865
  empty = FALSE;
2908
2866
  }
@@ -2965,7 +2923,7 @@ mrb_init_string(mrb_state *mrb)
2965
2923
  mrb_define_method(mrb, s, "slice", mrb_str_aref_m, MRB_ARGS_ANY()); /* 15.2.10.5.34 */
2966
2924
  mrb_define_method(mrb, s, "split", mrb_str_split_m, MRB_ARGS_ANY()); /* 15.2.10.5.35 */
2967
2925
 
2968
- #ifndef MRB_WITHOUT_FLOAT
2926
+ #ifndef MRB_NO_FLOAT
2969
2927
  mrb_define_method(mrb, s, "to_f", mrb_str_to_f, MRB_ARGS_NONE()); /* 15.2.10.5.38 */
2970
2928
  #endif
2971
2929
  mrb_define_method(mrb, s, "to_i", mrb_str_to_i, MRB_ARGS_ANY()); /* 15.2.10.5.39 */
@@ -2982,7 +2940,7 @@ mrb_init_string(mrb_state *mrb)
2982
2940
  mrb_define_method(mrb, s, "byteslice", mrb_str_byteslice, MRB_ARGS_ARG(1,1));
2983
2941
  }
2984
2942
 
2985
- #ifndef MRB_WITHOUT_FLOAT
2943
+ #ifndef MRB_NO_FLOAT
2986
2944
  /*
2987
2945
  * Source code for the "strtod" library procedure.
2988
2946
  *
@@ -3044,7 +3002,7 @@ mrb_float_read(const char *string, char **endPtr)
3044
3002
  int c;
3045
3003
  int exp = 0; /* Exponent read from "EX" field. */
3046
3004
  int fracExp = 0; /* Exponent that derives from the fractional
3047
- * part. Under normal circumstatnces, it is
3005
+ * part. Under normal circumstances, it is
3048
3006
  * the negative of the number of digits in F.
3049
3007
  * However, if I is very long, the last digits
3050
3008
  * of I get dropped (otherwise a long I with a