script_core 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (529) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +35 -57
  3. data/.ruby-version +1 -1
  4. data/Gemfile +2 -2
  5. data/README.md +7 -1
  6. data/ext/enterprise_script_service/Rakefile +1 -1
  7. data/ext/enterprise_script_service/libseccomp/.travis.yml +24 -12
  8. data/ext/enterprise_script_service/libseccomp/CHANGELOG +32 -0
  9. data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
  10. data/ext/enterprise_script_service/libseccomp/CREDITS +11 -0
  11. data/ext/enterprise_script_service/libseccomp/README.md +21 -1
  12. data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
  13. data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
  14. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
  15. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
  16. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
  17. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
  18. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
  19. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
  20. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
  21. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
  22. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
  23. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
  24. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
  25. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
  26. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
  27. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
  28. data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
  29. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +19 -0
  30. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
  31. data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
  32. data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
  33. data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
  34. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
  35. data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
  36. data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
  37. data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
  38. data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
  39. data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
  40. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
  41. data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
  42. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
  43. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
  44. data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
  45. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
  46. data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
  47. data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
  48. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
  49. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
  50. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
  51. data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
  52. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
  53. data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
  54. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
  55. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
  56. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
  57. data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
  58. data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
  59. data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
  60. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
  61. data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
  62. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
  63. data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
  64. data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
  65. data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
  66. data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
  67. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
  68. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
  69. data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
  70. data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
  71. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
  72. data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
  73. data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
  74. data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
  75. data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
  76. data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
  77. data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
  78. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +10 -2
  79. data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
  80. data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
  81. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
  82. data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
  83. data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +4 -3
  84. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
  85. data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
  86. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
  87. data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
  88. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
  89. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
  90. data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
  91. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
  92. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
  93. data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
  94. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
  95. data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
  96. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
  97. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
  98. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
  99. data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
  100. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
  101. data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
  102. data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
  103. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
  104. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
  105. data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
  106. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
  107. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
  108. data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
  109. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
  110. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
  111. data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
  112. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
  113. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
  114. data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
  115. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
  116. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
  117. data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
  118. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
  119. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
  120. data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
  121. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
  122. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
  123. data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
  124. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
  125. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
  126. data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
  127. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +34 -10
  128. data/ext/enterprise_script_service/libseccomp/tests/regression +10 -3
  129. data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
  130. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
  131. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
  132. data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
  133. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
  134. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +4 -0
  135. data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
  136. data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
  137. data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +149 -0
  138. data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +55 -0
  139. data/ext/enterprise_script_service/mruby/.github/workflows/lint.yml +23 -0
  140. data/ext/enterprise_script_service/mruby/.github/workflows/oss-fuzz.yml +27 -0
  141. data/ext/enterprise_script_service/mruby/.github/workflows/spell-checker.yml +17 -0
  142. data/ext/enterprise_script_service/mruby/.gitignore +3 -0
  143. data/ext/enterprise_script_service/mruby/.gitlab-ci.yml +3 -3
  144. data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
  145. data/ext/enterprise_script_service/mruby/.travis.yml +7 -10
  146. data/ext/enterprise_script_service/mruby/.yamllint +8 -0
  147. data/ext/enterprise_script_service/mruby/AUTHORS +4 -0
  148. data/ext/enterprise_script_service/mruby/CODEOWNERS +1 -0
  149. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +6 -13
  150. data/ext/enterprise_script_service/mruby/Doxyfile +4 -4
  151. data/ext/enterprise_script_service/mruby/LICENSE +1 -1
  152. data/ext/enterprise_script_service/mruby/Makefile +1 -1
  153. data/ext/enterprise_script_service/mruby/README.md +5 -11
  154. data/ext/enterprise_script_service/mruby/Rakefile +18 -108
  155. data/ext/enterprise_script_service/mruby/TODO.md +17 -0
  156. data/ext/enterprise_script_service/mruby/appveyor.yml +29 -26
  157. data/ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb +1 -1
  158. data/ext/enterprise_script_service/mruby/build_config.rb +9 -152
  159. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_ArduinoDue.rb → build_config/ArduinoDue.rb} +4 -21
  160. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +4 -4
  161. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +3 -20
  162. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +4 -21
  163. data/ext/enterprise_script_service/mruby/build_config/android_arm64-v8a.rb +11 -0
  164. data/ext/enterprise_script_service/mruby/build_config/android_armeabi.rb +11 -0
  165. 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
  166. data/ext/enterprise_script_service/mruby/build_config/bench.rb +11 -0
  167. data/ext/enterprise_script_service/mruby/build_config/boxing.rb +21 -0
  168. data/ext/enterprise_script_service/mruby/{examples/targets/build_config_chipKITMax32.rb → build_config/chipKITMax32.rb} +4 -21
  169. data/ext/enterprise_script_service/mruby/{appveyor_config.rb → build_config/ci/gcc-clang.rb} +11 -8
  170. data/ext/enterprise_script_service/mruby/build_config/ci/msvc.rb +20 -0
  171. data/ext/enterprise_script_service/mruby/build_config/clang-asan.rb +11 -0
  172. data/ext/enterprise_script_service/mruby/build_config/cross-32bit.rb +14 -0
  173. data/ext/enterprise_script_service/mruby/build_config/default.rb +80 -0
  174. data/ext/enterprise_script_service/mruby/build_config/dreamcast_shelf.rb +94 -0
  175. data/ext/enterprise_script_service/mruby/build_config/gameboyadvance.rb +73 -0
  176. data/ext/enterprise_script_service/mruby/build_config/host-cxx.rb +12 -0
  177. data/ext/enterprise_script_service/mruby/build_config/host-debug.rb +20 -0
  178. data/ext/enterprise_script_service/mruby/build_config/host-gprof.rb +14 -0
  179. data/ext/enterprise_script_service/mruby/build_config/host-m32.rb +15 -0
  180. data/ext/enterprise_script_service/mruby/build_config/host-shared.rb +36 -0
  181. data/ext/enterprise_script_service/mruby/build_config/mrbc.rb +11 -0
  182. data/ext/enterprise_script_service/mruby/build_config/no-float.rb +17 -0
  183. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +142 -49
  184. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +5 -4
  185. data/ext/enterprise_script_service/mruby/doc/guides/gc-arena-howto.md +1 -1
  186. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +53 -30
  187. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +31 -14
  188. data/ext/enterprise_script_service/mruby/doc/guides/symbol.md +83 -0
  189. data/ext/enterprise_script_service/mruby/doc/limitations.md +35 -36
  190. data/ext/enterprise_script_service/mruby/doc/mruby3.md +163 -0
  191. data/ext/enterprise_script_service/mruby/doc/opcode.md +102 -103
  192. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +1 -1
  193. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +5 -1
  194. data/ext/enterprise_script_service/mruby/examples/mrbgems/c_extension_example/src/example.c +5 -1
  195. data/ext/enterprise_script_service/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +1 -1
  196. data/ext/enterprise_script_service/mruby/include/mrbconf.h +88 -66
  197. data/ext/enterprise_script_service/mruby/include/mruby.h +160 -104
  198. data/ext/enterprise_script_service/mruby/include/mruby/array.h +27 -6
  199. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +80 -46
  200. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
  201. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +76 -55
  202. data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
  203. data/ext/enterprise_script_service/mruby/include/mruby/common.h +14 -1
  204. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +20 -6
  205. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  206. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +18 -52
  207. data/ext/enterprise_script_service/mruby/include/mruby/endian.h +44 -0
  208. data/ext/enterprise_script_service/mruby/include/mruby/error.h +39 -5
  209. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +1 -0
  210. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +33 -13
  211. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +74 -14
  212. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
  213. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +19 -9
  214. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +37 -63
  215. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
  216. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +29 -24
  217. data/ext/enterprise_script_service/mruby/include/mruby/presym.h +40 -0
  218. data/ext/enterprise_script_service/mruby/include/mruby/presym/disable.h +70 -0
  219. data/ext/enterprise_script_service/mruby/include/mruby/presym/enable.h +37 -0
  220. data/ext/enterprise_script_service/mruby/include/mruby/presym/scanning.h +73 -0
  221. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +93 -21
  222. data/ext/enterprise_script_service/mruby/include/mruby/string.h +12 -16
  223. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
  224. data/ext/enterprise_script_service/mruby/include/mruby/value.h +60 -59
  225. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
  226. data/ext/enterprise_script_service/mruby/include/mruby/version.h +25 -6
  227. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -72
  228. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +71 -78
  229. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +12 -10
  230. data/ext/enterprise_script_service/mruby/lib/{mruby-core-ext.rb → mruby/core_ext.rb} +10 -3
  231. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +84 -32
  232. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +1 -1
  233. data/ext/enterprise_script_service/mruby/lib/mruby/presym.rb +132 -0
  234. data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
  235. data/ext/enterprise_script_service/mruby/mrbgems/default-no-fpu.gembox +3 -0
  236. data/ext/enterprise_script_service/mruby/mrbgems/default-no-stdio.gembox +4 -0
  237. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +9 -81
  238. data/ext/enterprise_script_service/mruby/mrbgems/full-core.gembox +1 -4
  239. data/ext/enterprise_script_service/mruby/mrbgems/math.gembox +10 -0
  240. data/ext/enterprise_script_service/mruby/mrbgems/metaprog.gembox +15 -0
  241. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +1 -32
  242. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +10 -12
  243. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
  244. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +30 -18
  245. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mruby-config +18 -8
  246. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +3 -6
  247. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +10 -10
  248. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +14 -9
  249. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +3 -2
  250. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +4 -4
  251. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +2 -6
  252. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +6 -2
  253. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +23 -5
  254. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +11 -2
  255. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +46 -35
  256. data/ext/enterprise_script_service/mruby/mrbgems/{mruby-compiler → mruby-bin-mrbc}/bintest/mrbc.rb +0 -0
  257. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake +3 -4
  258. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +41 -28
  259. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +25 -4
  260. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -2
  261. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +26 -6
  262. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +1 -1
  263. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
  264. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrbgem.rake +5 -0
  265. data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrblib/catch.rb +27 -0
  266. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -1
  267. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +495 -436
  268. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +5 -0
  269. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +49 -44
  270. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +637 -220
  271. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13734 -0
  272. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +20 -23
  273. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +2 -2
  274. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +9 -9
  275. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +4 -4
  276. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +1 -0
  277. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +2 -2
  278. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/mrbgem.rake +2 -2
  279. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
  280. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +19 -238
  281. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
  282. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +19 -15
  283. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +31 -5
  284. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +7 -0
  285. data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +5 -6
  286. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +18 -16
  287. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
  288. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
  289. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
  290. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
  291. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +9 -14
  292. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +107 -59
  293. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +22 -38
  294. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +417 -203
  295. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +20 -12
  296. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +33 -2
  297. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +58 -50
  298. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +13 -14
  299. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +13 -12
  300. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/test/math.rb +5 -4
  301. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +56 -73
  302. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +13 -4
  303. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/README.md +4 -3
  304. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +80 -78
  305. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +4 -4
  306. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +14 -13
  307. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +8 -16
  308. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -13
  309. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/mrbgem.rake +10 -0
  310. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/src/memsize.c +231 -0
  311. data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/test/memsize.rb +63 -0
  312. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/README.md +15 -18
  313. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +120 -67
  314. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +1 -30
  315. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +65 -26
  316. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +34 -21
  317. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.c +1 -1
  318. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +98 -43
  319. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +2 -2
  320. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +39 -6
  321. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +21 -43
  322. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +27 -3
  323. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +12 -20
  324. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +216 -38
  325. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +6 -6
  326. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/README.md +6 -4
  327. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +5 -5
  328. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
  329. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
  330. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
  331. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
  332. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +161 -93
  333. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +9 -25
  334. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +23 -1
  335. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +17 -14
  336. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +1 -1
  337. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +23 -36
  338. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +7 -6
  339. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  340. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/README.md +0 -1
  341. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +5 -5
  342. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +17 -44
  343. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +4 -4
  344. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +37 -41
  345. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-ext.gembox +18 -0
  346. data/ext/enterprise_script_service/mruby/mrbgems/stdlib-io.gembox +12 -0
  347. data/ext/enterprise_script_service/mruby/mrbgems/stdlib.gembox +54 -0
  348. data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
  349. data/ext/enterprise_script_service/mruby/mrblib/10error.rb +4 -0
  350. data/ext/enterprise_script_service/mruby/mrblib/array.rb +17 -9
  351. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +1 -1
  352. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -23
  353. data/ext/enterprise_script_service/mruby/mrblib/init_mrblib.c +0 -11
  354. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +36 -11
  355. data/ext/enterprise_script_service/mruby/mrblib/range.rb +25 -3
  356. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +2 -2
  357. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +1 -1
  358. data/ext/enterprise_script_service/mruby/src/array.c +67 -90
  359. data/ext/enterprise_script_service/mruby/src/backtrace.c +18 -19
  360. data/ext/enterprise_script_service/mruby/src/class.c +819 -211
  361. data/ext/enterprise_script_service/mruby/src/codedump.c +226 -197
  362. data/ext/enterprise_script_service/mruby/src/debug.c +14 -11
  363. data/ext/enterprise_script_service/mruby/src/dump.c +470 -207
  364. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  365. data/ext/enterprise_script_service/mruby/src/error.c +94 -20
  366. data/ext/enterprise_script_service/mruby/src/etc.c +56 -39
  367. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +103 -27
  368. data/ext/enterprise_script_service/mruby/src/gc.c +86 -349
  369. data/ext/enterprise_script_service/mruby/src/hash.c +1058 -723
  370. data/ext/enterprise_script_service/mruby/src/kernel.c +78 -226
  371. data/ext/enterprise_script_service/mruby/src/load.c +215 -159
  372. data/ext/enterprise_script_service/mruby/src/numeric.c +400 -382
  373. data/ext/enterprise_script_service/mruby/src/object.c +115 -90
  374. data/ext/enterprise_script_service/mruby/src/print.c +31 -6
  375. data/ext/enterprise_script_service/mruby/src/proc.c +56 -45
  376. data/ext/enterprise_script_service/mruby/src/range.c +49 -33
  377. data/ext/enterprise_script_service/mruby/src/state.c +58 -42
  378. data/ext/enterprise_script_service/mruby/src/string.c +151 -156
  379. data/ext/enterprise_script_service/mruby/src/symbol.c +132 -66
  380. data/ext/enterprise_script_service/mruby/src/value_array.h +1 -0
  381. data/ext/enterprise_script_service/mruby/src/variable.c +158 -158
  382. data/ext/enterprise_script_service/mruby/src/vm.c +655 -645
  383. data/ext/enterprise_script_service/mruby/tasks/benchmark.rake +6 -6
  384. data/ext/enterprise_script_service/mruby/tasks/bin.rake +23 -0
  385. data/ext/enterprise_script_service/mruby/tasks/core.rake +12 -0
  386. data/ext/enterprise_script_service/mruby/tasks/doc.rake +50 -38
  387. data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +64 -61
  388. data/ext/enterprise_script_service/mruby/tasks/libmruby.rake +10 -1
  389. data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +13 -1
  390. data/ext/enterprise_script_service/mruby/tasks/mrblib.rake +40 -0
  391. data/ext/enterprise_script_service/mruby/tasks/presym.rake +44 -0
  392. data/ext/enterprise_script_service/mruby/tasks/test.rake +68 -0
  393. data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
  394. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +8 -7
  395. data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +13 -17
  396. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +21 -25
  397. data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
  398. data/ext/enterprise_script_service/mruby/test/bintest.rb +5 -5
  399. data/ext/enterprise_script_service/mruby/test/t/argumenterror.rb +16 -0
  400. data/ext/enterprise_script_service/mruby/test/t/array.rb +7 -3
  401. data/ext/enterprise_script_service/mruby/test/t/bs_literal.rb +1 -1
  402. data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
  403. data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
  404. data/ext/enterprise_script_service/mruby/test/t/float.rb +18 -8
  405. data/ext/enterprise_script_service/mruby/test/t/hash.rb +903 -281
  406. data/ext/enterprise_script_service/mruby/test/t/integer.rb +10 -38
  407. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +16 -25
  408. data/ext/enterprise_script_service/mruby/test/t/literals.rb +50 -0
  409. data/ext/enterprise_script_service/mruby/test/t/module.rb +2 -2
  410. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +1 -1
  411. data/ext/enterprise_script_service/mruby/test/t/range.rb +83 -1
  412. data/ext/enterprise_script_service/mruby/test/t/string.rb +4 -0
  413. data/ext/enterprise_script_service/mruby/test/t/superclass.rb +10 -10
  414. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +24 -0
  415. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +3 -3
  416. data/ext/enterprise_script_service/mruby_config.rb +2 -5
  417. data/ext/enterprise_script_service/mruby_engine.cpp +1 -1
  418. data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
  419. data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
  420. data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
  421. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
  422. data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
  423. data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
  424. data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
  425. data/ext/enterprise_script_service/msgpack/README.md +3 -2
  426. data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
  427. data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
  428. data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
  429. data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
  430. data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
  431. data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
  432. data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
  433. data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
  434. data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
  435. data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
  436. data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
  437. data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
  438. data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
  439. data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
  440. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
  441. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
  442. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
  443. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
  444. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
  445. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
  446. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
  447. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
  448. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
  449. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  450. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
  451. data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
  452. data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
  453. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
  454. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
  455. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
  456. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
  457. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
  458. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
  459. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
  460. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
  461. data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
  462. data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
  463. data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
  464. data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
  465. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
  466. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
  467. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
  468. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
  469. data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
  470. data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
  471. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
  472. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
  473. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
  474. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
  475. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
  476. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
  477. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
  478. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
  479. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
  480. data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
  481. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
  482. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
  483. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
  484. data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
  485. data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
  486. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
  487. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
  488. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
  489. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
  490. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
  491. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
  492. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
  493. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
  494. data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
  495. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
  496. data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
  497. data/lib/script_core/engine.rb +24 -5
  498. data/lib/script_core/executable.rb +4 -3
  499. data/lib/script_core/version.rb +1 -1
  500. data/lib/tasks/script_core.rake +3 -1
  501. data/script_core.gemspec +1 -2
  502. data/spec/dummy/app/lib/script_engine.rb +64 -5
  503. data/spec/script_core_spec.rb +13 -0
  504. metadata +123 -61
  505. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
  506. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
  507. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
  508. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
  509. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
  510. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
  511. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
  512. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
  513. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -626
  514. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -626
  515. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
  516. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
  517. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
  518. data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
  519. data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
  520. data/ext/enterprise_script_service/mruby/TODO +0 -8
  521. data/ext/enterprise_script_service/mruby/benchmark/build_config_boxing.rb +0 -28
  522. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_arm64-v8a.rb +0 -26
  523. data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_armeabi.rb +0 -26
  524. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +0 -30
  525. data/ext/enterprise_script_service/mruby/mrblib/mrblib.rake +0 -18
  526. data/ext/enterprise_script_service/mruby/src/crc.c +0 -39
  527. data/ext/enterprise_script_service/mruby/src/mruby_core.rake +0 -19
  528. data/ext/enterprise_script_service/mruby/travis_config.rb +0 -54
  529. data/ext/enterprise_script_service/msgpack/.travis.yml +0 -258
@@ -1,4 +1,9 @@
1
1
  %{
2
+ /* Workaround for `enable_cxx_exception` (#5199) */
3
+ #if defined __cplusplus && __cplusplus >= 201103L
4
+ # define register
5
+ #endif
6
+
2
7
  struct kwtable {const char *name; int id[2]; enum mrb_lex_state_enum state;};
3
8
  %}
4
9
 
@@ -1,5 +1,5 @@
1
1
  /* ANSI-C code produced by gperf version 3.1 */
2
- /* Command-line: gperf -L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k'1,3,$' /home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords */
2
+ /* Command-line: gperf -L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k'1,3,$' mrbgems/mruby-compiler/core/keywords */
3
3
 
4
4
  #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
5
5
  && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,10 +28,15 @@
28
28
  #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
29
29
  #endif
30
30
 
31
- #line 1 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
31
+ #line 1 "mrbgems/mruby-compiler/core/keywords"
32
+
33
+ /* Workaround for `enable_cxx_exception` (#5199) */
34
+ #if defined __cplusplus && __cplusplus >= 201103L
35
+ # define register
36
+ #endif
32
37
 
33
38
  struct kwtable {const char *name; int id[2]; enum mrb_lex_state_enum state;};
34
- #line 5 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
39
+ #line 10 "mrbgems/mruby-compiler/core/keywords"
35
40
  struct kwtable;
36
41
 
37
42
  #define TOTAL_KEYWORDS 40
@@ -101,87 +106,87 @@ mrb_reserved_word (register const char *str, register size_t len)
101
106
  static const struct kwtable wordlist[] =
102
107
  {
103
108
  {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
104
- #line 15 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
109
+ #line 20 "mrbgems/mruby-compiler/core/keywords"
105
110
  {"break", {keyword_break, keyword_break}, EXPR_MID},
106
- #line 20 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
111
+ #line 25 "mrbgems/mruby-compiler/core/keywords"
107
112
  {"else", {keyword_else, keyword_else}, EXPR_BEG},
108
- #line 30 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
113
+ #line 35 "mrbgems/mruby-compiler/core/keywords"
109
114
  {"nil", {keyword_nil, keyword_nil}, EXPR_END},
110
- #line 23 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
115
+ #line 28 "mrbgems/mruby-compiler/core/keywords"
111
116
  {"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG},
112
- #line 22 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
117
+ #line 27 "mrbgems/mruby-compiler/core/keywords"
113
118
  {"end", {keyword_end, keyword_end}, EXPR_END},
114
- #line 39 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
119
+ #line 44 "mrbgems/mruby-compiler/core/keywords"
115
120
  {"then", {keyword_then, keyword_then}, EXPR_BEG},
116
- #line 31 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
121
+ #line 36 "mrbgems/mruby-compiler/core/keywords"
117
122
  {"not", {keyword_not, keyword_not}, EXPR_ARG},
118
- #line 24 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
123
+ #line 29 "mrbgems/mruby-compiler/core/keywords"
119
124
  {"false", {keyword_false, keyword_false}, EXPR_END},
120
- #line 37 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
125
+ #line 42 "mrbgems/mruby-compiler/core/keywords"
121
126
  {"self", {keyword_self, keyword_self}, EXPR_END},
122
- #line 21 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
127
+ #line 26 "mrbgems/mruby-compiler/core/keywords"
123
128
  {"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
124
- #line 34 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
129
+ #line 39 "mrbgems/mruby-compiler/core/keywords"
125
130
  {"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
126
- #line 40 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
131
+ #line 45 "mrbgems/mruby-compiler/core/keywords"
127
132
  {"true", {keyword_true, keyword_true}, EXPR_END},
128
- #line 43 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
133
+ #line 48 "mrbgems/mruby-compiler/core/keywords"
129
134
  {"until", {keyword_until, modifier_until}, EXPR_VALUE},
130
- #line 42 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
135
+ #line 47 "mrbgems/mruby-compiler/core/keywords"
131
136
  {"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
132
- #line 36 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
137
+ #line 41 "mrbgems/mruby-compiler/core/keywords"
133
138
  {"return", {keyword_return, keyword_return}, EXPR_MID},
134
- #line 18 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
139
+ #line 23 "mrbgems/mruby-compiler/core/keywords"
135
140
  {"def", {keyword_def, keyword_def}, EXPR_FNAME},
136
- #line 13 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
141
+ #line 18 "mrbgems/mruby-compiler/core/keywords"
137
142
  {"and", {keyword_and, keyword_and}, EXPR_VALUE},
138
- #line 19 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
143
+ #line 24 "mrbgems/mruby-compiler/core/keywords"
139
144
  {"do", {keyword_do, keyword_do}, EXPR_BEG},
140
- #line 46 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
145
+ #line 51 "mrbgems/mruby-compiler/core/keywords"
141
146
  {"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
142
- #line 25 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
147
+ #line 30 "mrbgems/mruby-compiler/core/keywords"
143
148
  {"for", {keyword_for, keyword_for}, EXPR_VALUE},
144
- #line 41 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
149
+ #line 46 "mrbgems/mruby-compiler/core/keywords"
145
150
  {"undef", {keyword_undef, keyword_undef}, EXPR_FNAME},
146
- #line 32 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
151
+ #line 37 "mrbgems/mruby-compiler/core/keywords"
147
152
  {"or", {keyword_or, keyword_or}, EXPR_VALUE},
148
- #line 27 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
153
+ #line 32 "mrbgems/mruby-compiler/core/keywords"
149
154
  {"in", {keyword_in, keyword_in}, EXPR_VALUE},
150
- #line 44 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
155
+ #line 49 "mrbgems/mruby-compiler/core/keywords"
151
156
  {"when", {keyword_when, keyword_when}, EXPR_VALUE},
152
- #line 35 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
157
+ #line 40 "mrbgems/mruby-compiler/core/keywords"
153
158
  {"retry", {keyword_retry, keyword_retry}, EXPR_END},
154
- #line 26 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
159
+ #line 31 "mrbgems/mruby-compiler/core/keywords"
155
160
  {"if", {keyword_if, modifier_if}, EXPR_VALUE},
156
- #line 16 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
161
+ #line 21 "mrbgems/mruby-compiler/core/keywords"
157
162
  {"case", {keyword_case, keyword_case}, EXPR_VALUE},
158
- #line 33 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
163
+ #line 38 "mrbgems/mruby-compiler/core/keywords"
159
164
  {"redo", {keyword_redo, keyword_redo}, EXPR_END},
160
- #line 29 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
165
+ #line 34 "mrbgems/mruby-compiler/core/keywords"
161
166
  {"next", {keyword_next, keyword_next}, EXPR_MID},
162
- #line 38 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
167
+ #line 43 "mrbgems/mruby-compiler/core/keywords"
163
168
  {"super", {keyword_super, keyword_super}, EXPR_ARG},
164
- #line 28 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
169
+ #line 33 "mrbgems/mruby-compiler/core/keywords"
165
170
  {"module", {keyword_module, keyword_module}, EXPR_VALUE},
166
- #line 14 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
171
+ #line 19 "mrbgems/mruby-compiler/core/keywords"
167
172
  {"begin", {keyword_begin, keyword_begin}, EXPR_BEG},
168
- #line 9 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
173
+ #line 14 "mrbgems/mruby-compiler/core/keywords"
169
174
  {"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END},
170
- #line 8 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
175
+ #line 13 "mrbgems/mruby-compiler/core/keywords"
171
176
  {"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END},
172
- #line 7 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
177
+ #line 12 "mrbgems/mruby-compiler/core/keywords"
173
178
  {"__ENCODING__", {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
174
- #line 11 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
179
+ #line 16 "mrbgems/mruby-compiler/core/keywords"
175
180
  {"END", {keyword_END, keyword_END}, EXPR_END},
176
- #line 12 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
181
+ #line 17 "mrbgems/mruby-compiler/core/keywords"
177
182
  {"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
178
- #line 10 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
183
+ #line 15 "mrbgems/mruby-compiler/core/keywords"
179
184
  {"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
180
185
  {""},
181
- #line 17 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
186
+ #line 22 "mrbgems/mruby-compiler/core/keywords"
182
187
  {"class", {keyword_class, keyword_class}, EXPR_CLASS},
183
188
  {""}, {""},
184
- #line 45 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
189
+ #line 50 "mrbgems/mruby-compiler/core/keywords"
185
190
  {"while", {keyword_while, modifier_while}, EXPR_VALUE}
186
191
  };
187
192
 
@@ -199,5 +204,5 @@ mrb_reserved_word (register const char *str, register size_t len)
199
204
  }
200
205
  return 0;
201
206
  }
202
- #line 47 "/home/matz/work/mruby/mrbgems/mruby-compiler/core/keywords"
207
+ #line 52 "mrbgems/mruby-compiler/core/keywords"
203
208
 
@@ -9,7 +9,6 @@
9
9
  #ifdef PARSER_DEBUG
10
10
  # define YYDEBUG 1
11
11
  #endif
12
- #define YYERROR_VERBOSE 1
13
12
  #define YYSTACK_USE_ALLOCA 1
14
13
 
15
14
  #include <ctype.h>
@@ -22,6 +21,8 @@
22
21
  #include <mruby/error.h>
23
22
  #include <mruby/throw.h>
24
23
  #include <mruby/string.h>
24
+ #include <mruby/dump.h>
25
+ #include <mruby/presym.h>
25
26
  #include "node.h"
26
27
 
27
28
  #define YYLEX_PARAM p
@@ -70,6 +71,7 @@ typedef unsigned int stack_type;
70
71
  #define nsym(x) ((node*)(intptr_t)(x))
71
72
  #define nint(x) ((node*)(intptr_t)(x))
72
73
  #define intn(x) ((int)(intptr_t)(x))
74
+ #define typen(x) ((enum node_type)(intptr_t)(x))
73
75
 
74
76
  #define NUM_SUFFIX_R (1<<0)
75
77
  #define NUM_SUFFIX_I (1<<1)
@@ -88,7 +90,7 @@ intern_gen(parser_state *p, const char *s, size_t len)
88
90
  }
89
91
  #define intern(s,len) intern_gen(p,(s),(len))
90
92
 
91
- #define intern_lit(s) mrb_intern_lit(p->mrb, s)
93
+ #define intern_op(op) MRB_OPSYM_2(p->mrb, op)
92
94
 
93
95
  static void
94
96
  cons_free_gen(parser_state *p, node *cons)
@@ -266,6 +268,7 @@ local_unnest(parser_state *p)
266
268
  static mrb_bool
267
269
  local_var_p(parser_state *p, mrb_sym sym)
268
270
  {
271
+ const struct RProc *u;
269
272
  node *l = p->locals;
270
273
 
271
274
  while (l) {
@@ -276,6 +279,20 @@ local_var_p(parser_state *p, mrb_sym sym)
276
279
  }
277
280
  l = l->cdr;
278
281
  }
282
+
283
+ u = p->upper;
284
+ while (u && !MRB_PROC_CFUNC_P(u)) {
285
+ const struct mrb_irep *ir = u->body.irep;
286
+ const mrb_sym *v = ir->lv;
287
+ int i;
288
+
289
+ if (!v) break;
290
+ for (i=0; i+1 < ir->nlocals; i++) {
291
+ if (v[i] == sym) return TRUE;
292
+ }
293
+ if (MRB_PROC_SCOPE_P(u)) break;
294
+ u = u->upper;
295
+ }
279
296
  return FALSE;
280
297
  }
281
298
 
@@ -299,14 +316,14 @@ static void
299
316
  local_add_blk(parser_state *p, mrb_sym blk)
300
317
  {
301
318
  /* allocate register for block */
302
- local_add_f(p, blk ? blk : mrb_intern_lit(p->mrb, "&"));
319
+ local_add_f(p, blk ? blk : intern_op(and));
303
320
  }
304
321
 
305
322
  static void
306
323
  local_add_kw(parser_state *p, mrb_sym kwd)
307
324
  {
308
325
  /* allocate register for keywords hash */
309
- local_add_f(p, kwd ? kwd : mrb_intern_lit(p->mrb, "**"));
326
+ local_add_f(p, kwd ? kwd : intern_op(pow));
310
327
  }
311
328
 
312
329
  static node*
@@ -718,7 +735,19 @@ new_module(parser_state *p, node *m, node *b)
718
735
  static node*
719
736
  new_def(parser_state *p, mrb_sym m, node *a, node *b)
720
737
  {
721
- return list5((node*)NODE_DEF, nsym(m), locals_node(p), a, b);
738
+ return list5((node*)NODE_DEF, nsym(m), 0, a, b);
739
+ }
740
+
741
+ static void
742
+ defn_setup(parser_state *p, node *d, node *a, node *b)
743
+ {
744
+ node *n = d->cdr->cdr;
745
+
746
+ n->car = locals_node(p);
747
+ p->cmdarg_stack = intn(n->cdr->car);
748
+ n->cdr->car = a;
749
+ local_resume(p, n->cdr->cdr->car);
750
+ n->cdr->cdr->car = b;
722
751
  }
723
752
 
724
753
  /* (:sdef obj m lv (arg . body)) */
@@ -726,7 +755,19 @@ static node*
726
755
  new_sdef(parser_state *p, node *o, mrb_sym m, node *a, node *b)
727
756
  {
728
757
  void_expr_error(p, o);
729
- return list6((node*)NODE_SDEF, o, nsym(m), locals_node(p), a, b);
758
+ return list6((node*)NODE_SDEF, o, nsym(m), 0, a, b);
759
+ }
760
+
761
+ static void
762
+ defs_setup(parser_state *p, node *d, node *a, node *b)
763
+ {
764
+ node *n = d->cdr->cdr->cdr;
765
+
766
+ n->car = locals_node(p);
767
+ p->cmdarg_stack = intn(n->cdr->car);
768
+ n->cdr->car = a;
769
+ local_resume(p, n->cdr->cdr->car);
770
+ n->cdr->cdr->car = b;
730
771
  }
731
772
 
732
773
  /* (:arg . sym) */
@@ -740,7 +781,7 @@ static void
740
781
  local_add_margs(parser_state *p, node *n)
741
782
  {
742
783
  while (n) {
743
- if (n->car->car == (node*)NODE_MASGN) {
784
+ if (typen(n->car->car) == NODE_MASGN) {
744
785
  node *t = n->car->cdr->cdr;
745
786
 
746
787
  n->car->cdr->cdr = NULL;
@@ -827,6 +868,13 @@ new_kw_arg(parser_state *p, mrb_sym kw, node *def_arg)
827
868
  return list3((node*)NODE_KW_ARG, nsym(kw), def_arg);
828
869
  }
829
870
 
871
+ /* (:kw_rest_args . a) */
872
+ static node*
873
+ new_kw_rest_args(parser_state *p, node *a)
874
+ {
875
+ return cons((node*)NODE_KW_REST_ARGS, a);
876
+ }
877
+
830
878
  /* (:block_arg . a) */
831
879
  static node*
832
880
  new_block_arg(parser_state *p, node *a)
@@ -845,7 +893,8 @@ setup_numparams(parser_state *p, node *a)
845
893
  if (a && (a->car || (a->cdr && a->cdr->car) || (a->cdr->cdr && a->cdr->cdr->car) || (a->cdr->cdr->cdr->cdr && a->cdr->cdr->cdr->cdr->car))) {
846
894
  yyerror(p, "ordinary parameter is defined");
847
895
  }
848
- else {
896
+ else if (p->locals) {
897
+ /* p->locals should not be NULL unless error happens before the point */
849
898
  node* args = 0;
850
899
  for (i = nvars; i > 0; i--) {
851
900
  char buf[3];
@@ -912,13 +961,13 @@ new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
912
961
  static node*
913
962
  new_imaginary(parser_state *p, node *imaginary)
914
963
  {
915
- return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Complex"), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1);
964
+ return new_call(p, new_const(p, MRB_SYM_2(p->mrb, Kernel)), MRB_SYM_2(p->mrb, Complex), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1);
916
965
  }
917
966
 
918
967
  static node*
919
968
  new_rational(parser_state *p, node *rational)
920
969
  {
921
- return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Rational"), list1(list1(rational)), 1);
970
+ return new_call(p, new_const(p, MRB_SYM_2(p->mrb, Kernel)), MRB_SYM_2(p->mrb, Rational), list1(list1(rational)), 1);
922
971
  }
923
972
 
924
973
  /* (:int . i) */
@@ -935,7 +984,7 @@ new_int(parser_state *p, const char *s, int base, int suffix)
935
984
  return result;
936
985
  }
937
986
 
938
- #ifndef MRB_WITHOUT_FLOAT
987
+ #ifndef MRB_NO_FLOAT
939
988
  /* (:float . i) */
940
989
  static node*
941
990
  new_float(parser_state *p, const char *s, int suffix)
@@ -968,7 +1017,7 @@ new_dstr(parser_state *p, node *a)
968
1017
  static int
969
1018
  string_node_p(node *n)
970
1019
  {
971
- return (int)((enum node_type)(intptr_t)n->car == NODE_STR);
1020
+ return (int)(typen(n->car) == NODE_STR);
972
1021
  }
973
1022
 
974
1023
  static node*
@@ -1160,7 +1209,7 @@ call_with_block(parser_state *p, node *a, node *b)
1160
1209
  {
1161
1210
  node *n;
1162
1211
 
1163
- switch ((enum node_type)intn(a->car)) {
1212
+ switch (typen(a->car)) {
1164
1213
  case NODE_SUPER:
1165
1214
  case NODE_ZSUPER:
1166
1215
  if (!a->cdr) a->cdr = cons(0, b);
@@ -1234,7 +1283,7 @@ typedef enum mrb_string_type string_type;
1234
1283
  static node*
1235
1284
  new_strterm(parser_state *p, string_type type, int term, int paren)
1236
1285
  {
1237
- return cons(nint(type), cons((node*)0, cons(nint(paren), nint(term))));
1286
+ return cons(nint(type), cons(nint(0), cons(nint(paren), nint(term))));
1238
1287
  }
1239
1288
 
1240
1289
  static void
@@ -1322,7 +1371,8 @@ heredoc_end(parser_state *p)
1322
1371
 
1323
1372
  %}
1324
1373
 
1325
- %pure-parser
1374
+ %define parse.error verbose
1375
+ %define api.pure
1326
1376
  %parse-param {parser_state *p}
1327
1377
  %lex-param {parser_state *p}
1328
1378
 
@@ -1386,15 +1436,24 @@ heredoc_end(parser_state *p)
1386
1436
  keyword__FILE__
1387
1437
  keyword__ENCODING__
1388
1438
 
1389
- %token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL_TAG
1390
- %token <nd> tINTEGER tFLOAT tCHAR tXSTRING tREGEXP
1439
+ %token <id> tIDENTIFIER "local variable or method"
1440
+ %token <id> tFID "method"
1441
+ %token <id> tGVAR "global variable"
1442
+ %token <id> tIVAR "instance variable"
1443
+ %token <id> tCONSTANT "constant"
1444
+ %token <id> tCVAR "class variable"
1445
+ %token <id> tLABEL_TAG "label"
1446
+ %token <nd> tINTEGER "integer literal"
1447
+ %token <nd> tFLOAT "float literal"
1448
+ %token <nd> tCHAR "character literal"
1449
+ %token <nd> tXSTRING tREGEXP
1391
1450
  %token <nd> tSTRING tSTRING_PART tSTRING_MID
1392
1451
  %token <nd> tNTH_REF tBACK_REF
1393
1452
  %token <num> tREGEXP_END
1394
- %token <num> tNUMPARAM
1453
+ %token <num> tNUMPARAM "numbered paraemeter"
1395
1454
 
1396
1455
  %type <nd> singleton string string_fragment string_rep string_interp xstring regexp
1397
- %type <nd> literal numeric cpath symbol
1456
+ %type <nd> literal numeric cpath symbol defn_head defs_head
1398
1457
  %type <nd> top_compstmt top_stmts top_stmt
1399
1458
  %type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
1400
1459
  %type <nd> expr_value arg_rhs primary_value
@@ -1404,7 +1463,7 @@ heredoc_end(parser_state *p)
1404
1463
  %type <nd> command_args aref_args opt_block_arg block_arg var_ref var_lhs
1405
1464
  %type <nd> command_asgn command_rhs mrhs superclass block_call block_command
1406
1465
  %type <nd> f_block_optarg f_block_opt
1407
- %type <nd> f_arglist f_args f_arg f_arg_item f_optarg f_margs
1466
+ %type <nd> f_arglist_paren f_arglist f_args f_arg f_arg_item f_optarg f_margs
1408
1467
  %type <nd> assoc_list assocs assoc undef_list backref for_var
1409
1468
  %type <nd> block_param opt_block_param block_param_def f_opt
1410
1469
  %type <nd> bv_decls opt_bv_decl bvar f_larglist lambda_body
@@ -1419,38 +1478,41 @@ heredoc_end(parser_state *p)
1419
1478
  %type <nd> f_block_kwarg f_block_kw block_args_tail opt_block_args_tail
1420
1479
  %type <id> f_label
1421
1480
 
1422
- %token tUPLUS /* unary+ */
1423
- %token tUMINUS /* unary- */
1424
- %token tPOW /* ** */
1425
- %token tCMP /* <=> */
1426
- %token tEQ /* == */
1427
- %token tEQQ /* === */
1428
- %token tNEQ /* != */
1429
- %token tGEQ /* >= */
1430
- %token tLEQ /* <= */
1431
- %token tANDOP tOROP /* && and || */
1432
- %token tMATCH tNMATCH /* =~ and !~ */
1433
- %token tDOT2 tDOT3 /* .. and ... */
1481
+ %token tUPLUS "unary plus"
1482
+ %token tUMINUS "unary minus"
1483
+ %token tCMP "<=>"
1484
+ %token tEQ "=="
1485
+ %token tEQQ "==="
1486
+ %token tNEQ "!="
1487
+ %token tGEQ ">="
1488
+ %token tLEQ "<="
1489
+ %token tANDOP "&&"
1490
+ %token tOROP "||"
1491
+ %token tMATCH "=~"
1492
+ %token tNMATCH "!~"
1493
+ %token tDOT2 ".."
1494
+ %token tDOT3 "..."
1495
+ %token tBDOT2 tBDOT3 /* (.. and (... */
1434
1496
  %token tAREF tASET /* [] and []= */
1435
- %token tLSHFT tRSHFT /* << and >> */
1436
- %token tCOLON2 /* :: */
1497
+ %token tLSHFT "<<"
1498
+ %token tRSHFT ">>"
1499
+ %token tCOLON2 "::"
1437
1500
  %token tCOLON3 /* :: at EXPR_BEG */
1438
1501
  %token <id> tOP_ASGN /* +=, -= etc. */
1439
- %token tASSOC /* => */
1440
- %token tLPAREN /* ( */
1441
- %token tLPAREN_ARG /* ( */
1442
- %token tRPAREN /* ) */
1443
- %token tLBRACK /* [ */
1444
- %token tLBRACE /* { */
1445
- %token tLBRACE_ARG /* { */
1446
- %token tSTAR /* * */
1447
- %token tDSTAR /* ** */
1448
- %token tAMPER /* & */
1449
- %token tLAMBDA /* -> */
1450
- %token tANDDOT /* &. */
1451
- %token tSYMBEG tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG
1452
- %token tSTRING_BEG tXSTRING_BEG tSTRING_DVAR tLAMBEG
1453
- %token <nd> tHEREDOC_BEG /* <<, <<- */
1502
+ %token tASSOC "=>"
1503
+ %token tLPAREN tLPAREN_ARG "("
1504
+ %token tRPAREN ")"
1505
+ %token tLBRACK "["
1506
+ %token tLBRACE tLBRACE_ARG "{"
1507
+ %token tSTAR "*"
1508
+ %token tPOW tDSTAR "**"
1509
+ %token tAMPER "&"
1510
+ %token tLAMBDA "->"
1511
+ %token tANDDOT "&."
1512
+ %token tSYMBEG "symbol"
1513
+ %token tSTRING_BEG "string literal"
1514
+ %token tXSTRING_BEG tSTRING_DVAR tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG tLAMBEG
1515
+ %token <nd> tHEREDOC_BEG "here document"
1454
1516
  %token tHEREDOC_END tLITERAL_DELIM tHD_LITERAL_DELIM
1455
1517
  %token <nd> tHD_STRING_PART tHD_STRING_MID
1456
1518
 
@@ -1467,7 +1529,7 @@ heredoc_end(parser_state *p)
1467
1529
  %right '=' tOP_ASGN
1468
1530
  %left modifier_rescue
1469
1531
  %right '?' ':' tLABEL_TAG
1470
- %nonassoc tDOT2 tDOT3
1532
+ %nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
1471
1533
  %left tOROP
1472
1534
  %left tANDOP
1473
1535
  %nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
@@ -1637,6 +1699,13 @@ stmt : keyword_alias fsym {p->lstate = EXPR_FNAME;} fsym
1637
1699
  {
1638
1700
  $$ = new_masgn(p, $1, new_array(p, $3));
1639
1701
  }
1702
+ | arg tASSOC tIDENTIFIER
1703
+ {
1704
+ node *lhs = new_lvar(p, $3);
1705
+ void_expr_error(p, $1);
1706
+ assignable(p, lhs);
1707
+ $$ = new_asgn(p, lhs, $1);
1708
+ }
1640
1709
  | expr
1641
1710
  ;
1642
1711
 
@@ -1650,7 +1719,7 @@ command_asgn : lhs '=' command_rhs
1650
1719
  }
1651
1720
  | primary_value '[' opt_call_args ']' tOP_ASGN command_rhs
1652
1721
  {
1653
- $$ = new_op_asgn(p, new_call(p, $1, intern_lit("[]"), $3, '.'), $5, $6);
1722
+ $$ = new_op_asgn(p, new_call(p, $1, intern_op(aref), $3, '.'), $5, $6);
1654
1723
  }
1655
1724
  | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
1656
1725
  {
@@ -1705,6 +1774,31 @@ expr : command_call
1705
1774
  | arg
1706
1775
  ;
1707
1776
 
1777
+
1778
+ defn_head : keyword_def fname
1779
+ {
1780
+ $$ = new_def(p, $2, nint(p->cmdarg_stack), local_switch(p));
1781
+ p->cmdarg_stack = 0;
1782
+ p->in_def++;
1783
+ nvars_block(p);
1784
+ }
1785
+ ;
1786
+
1787
+ defs_head : keyword_def singleton dot_or_colon
1788
+ {
1789
+ p->lstate = EXPR_FNAME;
1790
+ }
1791
+ fname
1792
+ {
1793
+ $$ = new_sdef(p, $2, $5, nint(p->cmdarg_stack), local_switch(p));
1794
+ p->cmdarg_stack = 0;
1795
+ p->in_def++;
1796
+ p->in_single++;
1797
+ nvars_block(p);
1798
+ p->lstate = EXPR_ENDFN; /* force for args */
1799
+ }
1800
+ ;
1801
+
1708
1802
  expr_value : expr
1709
1803
  {
1710
1804
  if (!$1) $$ = new_nil(p);
@@ -1881,7 +1975,7 @@ mlhs_node : variable
1881
1975
  }
1882
1976
  | primary_value '[' opt_call_args ']'
1883
1977
  {
1884
- $$ = new_call(p, $1, intern_lit("[]"), $3, '.');
1978
+ $$ = new_call(p, $1, intern_op(aref), $3, '.');
1885
1979
  }
1886
1980
  | primary_value call_op tIDENTIFIER
1887
1981
  {
@@ -1920,7 +2014,7 @@ lhs : variable
1920
2014
  }
1921
2015
  | primary_value '[' opt_call_args ']'
1922
2016
  {
1923
- $$ = new_call(p, $1, intern_lit("[]"), $3, '.');
2017
+ $$ = new_call(p, $1, intern_op(aref), $3, '.');
1924
2018
  }
1925
2019
  | primary_value call_op tIDENTIFIER
1926
2020
  {
@@ -1966,11 +2060,11 @@ cname : tIDENTIFIER
1966
2060
 
1967
2061
  cpath : tCOLON3 cname
1968
2062
  {
1969
- $$ = cons((node*)1, nsym($2));
2063
+ $$ = cons(nint(1), nsym($2));
1970
2064
  }
1971
2065
  | cname
1972
2066
  {
1973
- $$ = cons((node*)0, nsym($1));
2067
+ $$ = cons(nint(0), nsym($1));
1974
2068
  }
1975
2069
  | primary_value tCOLON2 cname
1976
2070
  {
@@ -2008,36 +2102,36 @@ undef_list : fsym
2008
2102
  }
2009
2103
  ;
2010
2104
 
2011
- op : '|' { $$ = intern_lit("|"); }
2012
- | '^' { $$ = intern_lit("^"); }
2013
- | '&' { $$ = intern_lit("&"); }
2014
- | tCMP { $$ = intern_lit("<=>"); }
2015
- | tEQ { $$ = intern_lit("=="); }
2016
- | tEQQ { $$ = intern_lit("==="); }
2017
- | tMATCH { $$ = intern_lit("=~"); }
2018
- | tNMATCH { $$ = intern_lit("!~"); }
2019
- | '>' { $$ = intern_lit(">"); }
2020
- | tGEQ { $$ = intern_lit(">="); }
2021
- | '<' { $$ = intern_lit("<"); }
2022
- | tLEQ { $$ = intern_lit("<="); }
2023
- | tNEQ { $$ = intern_lit("!="); }
2024
- | tLSHFT { $$ = intern_lit("<<"); }
2025
- | tRSHFT { $$ = intern_lit(">>"); }
2026
- | '+' { $$ = intern_lit("+"); }
2027
- | '-' { $$ = intern_lit("-"); }
2028
- | '*' { $$ = intern_lit("*"); }
2029
- | tSTAR { $$ = intern_lit("*"); }
2030
- | '/' { $$ = intern_lit("/"); }
2031
- | '%' { $$ = intern_lit("%"); }
2032
- | tPOW { $$ = intern_lit("**"); }
2033
- | tDSTAR { $$ = intern_lit("**"); }
2034
- | '!' { $$ = intern_lit("!"); }
2035
- | '~' { $$ = intern_lit("~"); }
2036
- | tUPLUS { $$ = intern_lit("+@"); }
2037
- | tUMINUS { $$ = intern_lit("-@"); }
2038
- | tAREF { $$ = intern_lit("[]"); }
2039
- | tASET { $$ = intern_lit("[]="); }
2040
- | '`' { $$ = intern_lit("`"); }
2105
+ op : '|' { $$ = intern_op(or); }
2106
+ | '^' { $$ = intern_op(xor); }
2107
+ | '&' { $$ = intern_op(and); }
2108
+ | tCMP { $$ = intern_op(cmp); }
2109
+ | tEQ { $$ = intern_op(eq); }
2110
+ | tEQQ { $$ = intern_op(eqq); }
2111
+ | tMATCH { $$ = intern_op(match); }
2112
+ | tNMATCH { $$ = intern_op(nmatch); }
2113
+ | '>' { $$ = intern_op(gt); }
2114
+ | tGEQ { $$ = intern_op(ge); }
2115
+ | '<' { $$ = intern_op(lt); }
2116
+ | tLEQ { $$ = intern_op(le); }
2117
+ | tNEQ { $$ = intern_op(neq); }
2118
+ | tLSHFT { $$ = intern_op(lshift); }
2119
+ | tRSHFT { $$ = intern_op(rshift); }
2120
+ | '+' { $$ = intern_op(add); }
2121
+ | '-' { $$ = intern_op(sub); }
2122
+ | '*' { $$ = intern_op(mul); }
2123
+ | tSTAR { $$ = intern_op(mul); }
2124
+ | '/' { $$ = intern_op(div); }
2125
+ | '%' { $$ = intern_op(mod); }
2126
+ | tPOW { $$ = intern_op(pow); }
2127
+ | tDSTAR { $$ = intern_op(pow); }
2128
+ | '!' { $$ = intern_op(not); }
2129
+ | '~' { $$ = intern_op(neg); }
2130
+ | tUPLUS { $$ = intern_op(plus); }
2131
+ | tUMINUS { $$ = intern_op(minus); }
2132
+ | tAREF { $$ = intern_op(aref); }
2133
+ | tASET { $$ = intern_op(aset); }
2134
+ | '`' { $$ = intern_op(tick); }
2041
2135
  ;
2042
2136
 
2043
2137
  reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
@@ -2064,7 +2158,7 @@ arg : lhs '=' arg_rhs
2064
2158
  }
2065
2159
  | primary_value '[' opt_call_args ']' tOP_ASGN arg_rhs
2066
2160
  {
2067
- $$ = new_op_asgn(p, new_call(p, $1, intern_lit("[]"), $3, '.'), $5, $6);
2161
+ $$ = new_op_asgn(p, new_call(p, $1, intern_op(aref), $3, '.'), $5, $6);
2068
2162
  }
2069
2163
  | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
2070
2164
  {
@@ -2097,10 +2191,26 @@ arg : lhs '=' arg_rhs
2097
2191
  {
2098
2192
  $$ = new_dot2(p, $1, $3);
2099
2193
  }
2194
+ | arg tDOT2
2195
+ {
2196
+ $$ = new_dot2(p, $1, new_nil(p));
2197
+ }
2198
+ | tBDOT2 arg
2199
+ {
2200
+ $$ = new_dot2(p, new_nil(p), $2);
2201
+ }
2100
2202
  | arg tDOT3 arg
2101
2203
  {
2102
2204
  $$ = new_dot3(p, $1, $3);
2103
2205
  }
2206
+ | arg tDOT3
2207
+ {
2208
+ $$ = new_dot3(p, $1, new_nil(p));
2209
+ }
2210
+ | tBDOT3 arg
2211
+ {
2212
+ $$ = new_dot3(p, new_nil(p), $2);
2213
+ }
2104
2214
  | arg '+' arg
2105
2215
  {
2106
2216
  $$ = call_bin_op(p, $1, "+", $3);
@@ -2225,6 +2335,42 @@ arg : lhs '=' arg_rhs
2225
2335
  {
2226
2336
  $$ = new_if(p, cond($1), $3, $6);
2227
2337
  }
2338
+ | defn_head f_arglist_paren '=' arg
2339
+ {
2340
+ $$ = $1;
2341
+ void_expr_error(p, $4);
2342
+ defn_setup(p, $$, $2, $4);
2343
+ nvars_unnest(p);
2344
+ p->in_def--;
2345
+ }
2346
+ | defn_head f_arglist_paren '=' arg modifier_rescue arg
2347
+ {
2348
+ $$ = $1;
2349
+ void_expr_error(p, $4);
2350
+ void_expr_error(p, $6);
2351
+ defn_setup(p, $$, $2, new_mod_rescue(p, $4, $6));
2352
+ nvars_unnest(p);
2353
+ p->in_def--;
2354
+ }
2355
+ | defs_head f_arglist_paren '=' arg
2356
+ {
2357
+ $$ = $1;
2358
+ void_expr_error(p, $4);
2359
+ defs_setup(p, $$, $2, $4);
2360
+ nvars_unnest(p);
2361
+ p->in_def--;
2362
+ p->in_single--;
2363
+ }
2364
+ | defs_head f_arglist_paren '=' arg modifier_rescue arg
2365
+ {
2366
+ $$ = $1;
2367
+ void_expr_error(p, $4);
2368
+ void_expr_error(p, $6);
2369
+ defs_setup(p, $$, $2, new_mod_rescue(p, $4, $6));
2370
+ nvars_unnest(p);
2371
+ p->in_def--;
2372
+ p->in_single--;
2373
+ }
2228
2374
  | primary
2229
2375
  {
2230
2376
  $$ = $1;
@@ -2264,6 +2410,46 @@ paren_args : '(' opt_call_args ')'
2264
2410
  {
2265
2411
  $$ = $2;
2266
2412
  }
2413
+ | '(' args comma tBDOT3 rparen
2414
+ {
2415
+ #if 1
2416
+ mrb_sym r = intern_op(mul);
2417
+ mrb_sym b = intern_op(and);
2418
+ $$ = cons(push($2, new_splat(p, new_lvar(p, r))),
2419
+ new_block_arg(p, new_lvar(p, b)));
2420
+ #else
2421
+ mrb_sym r = intern_op(mul);
2422
+ mrb_sym k = intern_op(pow);
2423
+ mrb_sym b = intern_op(and);
2424
+ $$ = cons(list2(push($2, new_splat(p, new_lvar(p, r))),
2425
+ new_kw_hash(p, list1(cons(new_kw_rest_args(p, 0), new_lvar(p, k))))),
2426
+ new_block_arg(p, new_lvar(p, b)));
2427
+ #endif
2428
+ }
2429
+ | '(' tBDOT3 rparen
2430
+ {
2431
+ #if 1
2432
+ mrb_sym r = intern_op(mul);
2433
+ mrb_sym b = intern_op(and);
2434
+ if (local_var_p(p, r) && local_var_p(p, b)) {
2435
+ $$ = cons(list1(new_splat(p, new_lvar(p, r))),
2436
+ new_block_arg(p, new_lvar(p, b)));
2437
+ }
2438
+ #else
2439
+ mrb_sym r = intern_op(mul);
2440
+ mrb_sym k = intern_op(pow);
2441
+ mrb_sym b = intern_op(and);
2442
+ if (local_var_p(p, r) && local_var_p(p, k) && local_var_p(p, b)) {
2443
+ $$ = cons(list2(new_splat(p, new_lvar(p, r)),
2444
+ new_kw_hash(p, list1(cons(new_kw_rest_args(p, 0), new_lvar(p, k))))),
2445
+ new_block_arg(p, new_lvar(p, b)));
2446
+ }
2447
+ #endif
2448
+ else {
2449
+ yyerror(p, "unexpected argument forwarding ...");
2450
+ $$ = 0;
2451
+ }
2452
+ }
2267
2453
  ;
2268
2454
 
2269
2455
  opt_paren_args : none
@@ -2600,50 +2786,26 @@ primary : literal
2600
2786
  local_resume(p, $<nd>3);
2601
2787
  nvars_unnest(p);
2602
2788
  }
2603
- | keyword_def fname
2604
- {
2605
- $<stack>$ = p->cmdarg_stack;
2606
- p->cmdarg_stack = 0;
2607
- }
2608
- {
2609
- p->in_def++;
2610
- $<nd>$ = local_switch(p);
2611
- nvars_block(p);
2612
- }
2789
+ | defn_head
2613
2790
  f_arglist
2614
2791
  bodystmt
2615
2792
  keyword_end
2616
2793
  {
2617
- $$ = new_def(p, $2, $5, $6);
2618
- SET_LINENO($$, $1);
2619
- local_resume(p, $<nd>4);
2794
+ $$ = $1;
2795
+ defn_setup(p, $$, $2, $3);
2620
2796
  nvars_unnest(p);
2621
2797
  p->in_def--;
2622
- p->cmdarg_stack = $<stack>3;
2623
- }
2624
- | keyword_def singleton dot_or_colon
2625
- {
2626
- p->lstate = EXPR_FNAME;
2627
- $<stack>$ = p->cmdarg_stack;
2628
- p->cmdarg_stack = 0;
2629
- }
2630
- fname
2631
- {
2632
- p->in_single++;
2633
- p->lstate = EXPR_ENDFN; /* force for args */
2634
- $<nd>$ = local_switch(p);
2635
- nvars_block(p);
2636
2798
  }
2799
+ | defs_head
2637
2800
  f_arglist
2638
2801
  bodystmt
2639
2802
  keyword_end
2640
2803
  {
2641
- $$ = new_sdef(p, $2, $5, $7, $8);
2642
- SET_LINENO($$, $1);
2643
- local_resume(p, $<nd>6);
2804
+ $$ = $1;
2805
+ defs_setup(p, $$, $2, $3);
2644
2806
  nvars_unnest(p);
2807
+ p->in_def--;
2645
2808
  p->in_single--;
2646
- p->cmdarg_stack = $<stack>4;
2647
2809
  }
2648
2810
  | keyword_break
2649
2811
  {
@@ -2717,11 +2879,11 @@ f_margs : f_arg
2717
2879
  | f_arg ',' tSTAR
2718
2880
  {
2719
2881
  local_add_f(p, 0);
2720
- $$ = list3($1, (node*)-1, 0);
2882
+ $$ = list3($1, nint(-1), 0);
2721
2883
  }
2722
2884
  | f_arg ',' tSTAR ',' f_arg
2723
2885
  {
2724
- $$ = list3($1, (node*)-1, $5);
2886
+ $$ = list3($1, nint(-1), $5);
2725
2887
  }
2726
2888
  | tSTAR f_norm_arg
2727
2889
  {
@@ -2734,7 +2896,7 @@ f_margs : f_arg
2734
2896
  | tSTAR
2735
2897
  {
2736
2898
  local_add_f(p, 0);
2737
- $$ = list3(0, (node*)-1, 0);
2899
+ $$ = list3(0, nint(-1), 0);
2738
2900
  }
2739
2901
  | tSTAR ','
2740
2902
  {
@@ -2742,7 +2904,7 @@ f_margs : f_arg
2742
2904
  }
2743
2905
  f_arg
2744
2906
  {
2745
- $$ = list3(0, (node*)-1, $4);
2907
+ $$ = list3(0, nint(-1), $4);
2746
2908
  }
2747
2909
  ;
2748
2910
 
@@ -2923,7 +3085,7 @@ do_block : keyword_do_block
2923
3085
 
2924
3086
  block_call : command do_block
2925
3087
  {
2926
- if ($1->car == (node*)NODE_YIELD) {
3088
+ if (typen($1->car) == NODE_YIELD) {
2927
3089
  yyerror(p, "block given to yield");
2928
3090
  }
2929
3091
  else {
@@ -2965,11 +3127,11 @@ method_call : operation paren_args
2965
3127
  }
2966
3128
  | primary_value call_op paren_args
2967
3129
  {
2968
- $$ = new_call(p, $1, intern_lit("call"), $3, $2);
3130
+ $$ = new_call(p, $1, MRB_SYM_2(p->mrb, call), $3, $2);
2969
3131
  }
2970
3132
  | primary_value tCOLON2 paren_args
2971
3133
  {
2972
- $$ = new_call(p, $1, intern_lit("call"), $3, tCOLON2);
3134
+ $$ = new_call(p, $1, MRB_SYM_2(p->mrb, call), $3, tCOLON2);
2973
3135
  }
2974
3136
  | keyword_super paren_args
2975
3137
  {
@@ -2981,7 +3143,7 @@ method_call : operation paren_args
2981
3143
  }
2982
3144
  | primary_value '[' opt_call_args ']'
2983
3145
  {
2984
- $$ = new_call(p, $1, intern_lit("[]"), $3, '.');
3146
+ $$ = new_call(p, $1, intern_op(aref), $3, '.');
2985
3147
  }
2986
3148
  ;
2987
3149
 
@@ -3354,12 +3516,51 @@ superclass : /* term */
3354
3516
  } */
3355
3517
  ;
3356
3518
 
3357
- f_arglist : '(' f_args rparen
3519
+ f_arglist_paren : '(' f_args rparen
3358
3520
  {
3359
3521
  $$ = $2;
3360
3522
  p->lstate = EXPR_BEG;
3361
3523
  p->cmd_start = TRUE;
3362
3524
  }
3525
+ | '(' f_arg ',' tBDOT3 rparen
3526
+ {
3527
+ #if 1
3528
+ /* til real keyword args implemented */
3529
+ mrb_sym r = intern_op(mul);
3530
+ mrb_sym b = intern_op(and);
3531
+ local_add_f(p, r);
3532
+ $$ = new_args(p, $2, 0, r, 0,
3533
+ new_args_tail(p, 0, 0, b));
3534
+ #else
3535
+ mrb_sym r = intern_op(mul);
3536
+ mrb_sym k = intern_op(pow);
3537
+ mrb_sym b = intern_op(and);
3538
+ local_add_f(p, r); local_add_f(p, k);
3539
+ $$ = new_args(p, $2, 0, r, 0,
3540
+ new_args_tail(p, 0, new_kw_rest_args(p, nsym(k)), b));
3541
+ #endif
3542
+ }
3543
+ | '(' tBDOT3 rparen
3544
+ {
3545
+ #if 1
3546
+ /* til real keyword args implemented */
3547
+ mrb_sym r = intern_op(mul);
3548
+ mrb_sym b = intern_op(and);
3549
+ local_add_f(p, r);
3550
+ $$ = new_args(p, 0, 0, r, 0,
3551
+ new_args_tail(p, 0, 0, b));
3552
+ #else
3553
+ mrb_sym r = intern_op(mul);
3554
+ mrb_sym k = intern_op(pow);
3555
+ mrb_sym b = intern_op(and);
3556
+ local_add_f(p, r); local_add_f(p, k);
3557
+ $$ = new_args(p, 0, 0, r, 0,
3558
+ new_args_tail(p, 0, new_kw_rest_args(p, nsym(k)), b));
3559
+ #endif
3560
+ }
3561
+ ;
3562
+
3563
+ f_arglist : f_arglist_paren
3363
3564
  | f_args term
3364
3565
  {
3365
3566
  $$ = $1;
@@ -3423,11 +3624,11 @@ kwrest_mark : tPOW
3423
3624
 
3424
3625
  f_kwrest : kwrest_mark tIDENTIFIER
3425
3626
  {
3426
- $$ = cons((node*)NODE_KW_REST_ARGS, nsym($2));
3627
+ $$ = new_kw_rest_args(p, nsym($2));
3427
3628
  }
3428
3629
  | kwrest_mark
3429
3630
  {
3430
- $$ = cons((node*)NODE_KW_REST_ARGS, 0);
3631
+ $$ = new_kw_rest_args(p, 0);
3431
3632
  }
3432
3633
  ;
3433
3634
 
@@ -3517,7 +3718,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail
3517
3718
  }
3518
3719
  | /* none */
3519
3720
  {
3520
- local_add_f(p, mrb_intern_lit(p->mrb, "&"));
3721
+ local_add_f(p, intern_op(and));
3521
3722
  $$ = new_args(p, 0, 0, 0, 0, 0);
3522
3723
  }
3523
3724
  ;
@@ -3641,7 +3842,7 @@ f_rest_arg : restarg_mark tIDENTIFIER
3641
3842
  }
3642
3843
  | restarg_mark
3643
3844
  {
3644
- local_add_f(p, mrb_intern_lit(p->mrb, "*"));
3845
+ local_add_f(p, intern_op(mul));
3645
3846
  $$ = -1;
3646
3847
  }
3647
3848
  ;
@@ -3677,7 +3878,7 @@ singleton : var_ref
3677
3878
  yyerror(p, "can't define singleton method for ().");
3678
3879
  }
3679
3880
  else {
3680
- switch ((enum node_type)intn($3->car)) {
3881
+ switch (typen($3->car)) {
3681
3882
  case NODE_STR:
3682
3883
  case NODE_DSTR:
3683
3884
  case NODE_XSTR:
@@ -3732,7 +3933,7 @@ assoc : arg tASSOC arg
3732
3933
  | string_fragment label_tag arg
3733
3934
  {
3734
3935
  void_expr_error(p, $3);
3735
- if ($1->car == (node*)NODE_DSTR) {
3936
+ if (typen($1->car) == NODE_DSTR) {
3736
3937
  $$ = cons(new_dsym(p, $1), $3);
3737
3938
  }
3738
3939
  else {
@@ -3742,7 +3943,7 @@ assoc : arg tASSOC arg
3742
3943
  | tDSTAR arg
3743
3944
  {
3744
3945
  void_expr_error(p, $2);
3745
- $$ = cons(cons((node*)NODE_KW_REST_ARGS, 0), $2);
3946
+ $$ = cons(new_kw_rest_args(p, 0), $2);
3746
3947
  }
3747
3948
  ;
3748
3949
 
@@ -3806,7 +4007,7 @@ term : ';' {yyerrok;}
3806
4007
 
3807
4008
  nl : '\n'
3808
4009
  {
3809
- p->lineno++;
4010
+ p->lineno += $<num>1;
3810
4011
  p->column = 0;
3811
4012
  }
3812
4013
  ;
@@ -3830,7 +4031,7 @@ yyerror(parser_state *p, const char *s)
3830
4031
  size_t n;
3831
4032
 
3832
4033
  if (! p->capture_errors) {
3833
- #ifndef MRB_DISABLE_STDIO
4034
+ #ifndef MRB_NO_STDIO
3834
4035
  if (p->filename_sym) {
3835
4036
  const char *filename = mrb_sym_name_len(p->mrb, p->filename_sym, NULL);
3836
4037
  fprintf(stderr, "%s:%d:%d: %s\n", filename, p->lineno, p->column, s);
@@ -3869,7 +4070,7 @@ yywarn(parser_state *p, const char *s)
3869
4070
  size_t n;
3870
4071
 
3871
4072
  if (! p->capture_errors) {
3872
- #ifndef MRB_DISABLE_STDIO
4073
+ #ifndef MRB_NO_STDIO
3873
4074
  if (p->filename_sym) {
3874
4075
  const char *filename = mrb_sym_name_len(p->mrb, p->filename_sym, NULL);
3875
4076
  fprintf(stderr, "%s:%d:%d: warning: %s\n", filename, p->lineno, p->column, s);
@@ -3965,6 +4166,27 @@ static void pushback(parser_state *p, int c);
3965
4166
  static mrb_bool peeks(parser_state *p, const char *s);
3966
4167
  static mrb_bool skips(parser_state *p, const char *s);
3967
4168
 
4169
+ static inline int
4170
+ nextc0(parser_state *p)
4171
+ {
4172
+ int c;
4173
+
4174
+ if (p->s && p->s < p->send) {
4175
+ c = (unsigned char)*p->s++;
4176
+ }
4177
+ else {
4178
+ #ifndef MRB_NO_STDIO
4179
+ if (p->f) {
4180
+ c = fgetc(p->f);
4181
+ if (feof(p->f)) return -1;
4182
+ }
4183
+ else
4184
+ #endif
4185
+ return -1;
4186
+ }
4187
+ return c;
4188
+ }
4189
+
3968
4190
  static inline int
3969
4191
  nextc(parser_state *p)
3970
4192
  {
@@ -3979,30 +4201,18 @@ nextc(parser_state *p)
3979
4201
  cons_free(tmp);
3980
4202
  }
3981
4203
  else {
3982
- #ifndef MRB_DISABLE_STDIO
3983
- if (p->f) {
3984
- if (feof(p->f)) goto eof;
3985
- c = fgetc(p->f);
3986
- if (c == EOF) goto eof;
3987
- }
3988
- else
3989
- #endif
3990
- if (!p->s || p->s >= p->send) {
3991
- goto eof;
3992
- }
3993
- else {
3994
- c = (unsigned char)*p->s++;
3995
- }
4204
+ c = nextc0(p);
4205
+ if (c < 0) goto eof;
3996
4206
  }
3997
4207
  if (c >= 0) {
3998
4208
  p->column++;
3999
4209
  }
4000
4210
  if (c == '\r') {
4001
- const int lf = nextc(p);
4211
+ const int lf = nextc0(p);
4002
4212
  if (lf == '\n') {
4003
4213
  return '\n';
4004
4214
  }
4005
- pushback(p, lf);
4215
+ if (lf > 0) pushback(p, lf);
4006
4216
  }
4007
4217
  return c;
4008
4218
 
@@ -4049,7 +4259,7 @@ peekc_n(parser_state *p, int n)
4049
4259
  list = push(list, nint(c0));
4050
4260
  } while(n--);
4051
4261
  if (p->pb) {
4052
- p->pb = append((node*)list, p->pb);
4262
+ p->pb = append(list, p->pb);
4053
4263
  }
4054
4264
  else {
4055
4265
  p->pb = list;
@@ -4069,7 +4279,7 @@ peeks(parser_state *p, const char *s)
4069
4279
  {
4070
4280
  size_t len = strlen(s);
4071
4281
 
4072
- #ifndef MRB_DISABLE_STDIO
4282
+ #ifndef MRB_NO_STDIO
4073
4283
  if (p->f) {
4074
4284
  int n = 0;
4075
4285
  while (*s) {
@@ -4427,6 +4637,88 @@ read_escape(parser_state *p)
4427
4637
  }
4428
4638
  }
4429
4639
 
4640
+ static void
4641
+ heredoc_count_indent(parser_heredoc_info *hinf, const char *str, size_t len, size_t spaces, size_t *offset)
4642
+ {
4643
+ size_t indent = 0;
4644
+ *offset = 0;
4645
+ for (size_t i = 0; i < len; i++) {
4646
+ size_t size;
4647
+ if (str[i] == '\n')
4648
+ break;
4649
+ else if (str[i] == '\t')
4650
+ size = 8;
4651
+ else if (ISSPACE(str[i]))
4652
+ size = 1;
4653
+ else
4654
+ break;
4655
+ size_t nindent = indent + size;
4656
+ if (nindent > spaces || nindent > hinf->indent)
4657
+ break;
4658
+ indent = nindent;
4659
+ *offset += 1;
4660
+ }
4661
+ }
4662
+
4663
+ static void
4664
+ heredoc_remove_indent(parser_state *p, parser_heredoc_info *hinf)
4665
+ {
4666
+ if (!hinf->remove_indent || hinf->indent == 0)
4667
+ return;
4668
+ node *indented, *n, *pair, *escaped, *nspaces;
4669
+ const char *str;
4670
+ size_t len, spaces, offset, start, end;
4671
+ indented = hinf->indented;
4672
+ while (indented) {
4673
+ n = indented->car;
4674
+ pair = n->car;
4675
+ str = (char*)pair->car;
4676
+ len = (size_t)pair->cdr;
4677
+ escaped = n->cdr->car;
4678
+ nspaces = n->cdr->cdr;
4679
+ if (escaped) {
4680
+ char *newstr = strndup(str, len);
4681
+ size_t newlen = 0;
4682
+ start = 0;
4683
+ while (start < len) {
4684
+ end = escaped ? (size_t)escaped->car : len;
4685
+ spaces = (size_t)nspaces->car;
4686
+ size_t esclen = end - start;
4687
+ heredoc_count_indent(hinf, str + start, esclen, spaces, &offset);
4688
+ esclen -= offset;
4689
+ memcpy(newstr + newlen, str + start + offset, esclen);
4690
+ newlen += esclen;
4691
+ start = end;
4692
+ if (escaped)
4693
+ escaped = escaped->cdr;
4694
+ nspaces = nspaces->cdr;
4695
+ }
4696
+ if (newlen < len)
4697
+ newstr[newlen] = '\0';
4698
+ pair->car = (node*)newstr;
4699
+ pair->cdr = (node*)newlen;
4700
+ } else {
4701
+ spaces = (size_t)nspaces->car;
4702
+ heredoc_count_indent(hinf, str, len, spaces, &offset);
4703
+ pair->car = (node*)(str + offset);
4704
+ pair->cdr = (node*)(len - offset);
4705
+ }
4706
+ indented = indented->cdr;
4707
+ }
4708
+ }
4709
+
4710
+ static void
4711
+ heredoc_push_indented(parser_state *p, parser_heredoc_info *hinf, node *pair, node *escaped, node *nspaces, mrb_bool empty_line)
4712
+ {
4713
+ hinf->indented = push(hinf->indented, cons(pair, cons(escaped, nspaces)));
4714
+ while (nspaces) {
4715
+ size_t tspaces = (size_t)nspaces->car;
4716
+ if ((hinf->indent == ~0U || tspaces < hinf->indent) && !empty_line)
4717
+ hinf->indent = tspaces;
4718
+ nspaces = nspaces->cdr;
4719
+ }
4720
+ }
4721
+
4430
4722
  static int
4431
4723
  parse_string(parser_state *p)
4432
4724
  {
@@ -4437,10 +4729,19 @@ parse_string(parser_state *p)
4437
4729
  int end = intn(p->lex_strterm->cdr->cdr->cdr);
4438
4730
  parser_heredoc_info *hinf = (type & STR_FUNC_HEREDOC) ? parsing_heredoc_inf(p) : NULL;
4439
4731
 
4732
+ mrb_bool unindent = hinf && hinf->remove_indent;
4733
+ mrb_bool head = hinf && hinf->line_head;
4734
+ mrb_bool empty = TRUE;
4735
+ size_t spaces = 0;
4736
+ size_t pos = -1;
4737
+ node *escaped = NULL;
4738
+ node *nspaces = NULL;
4739
+
4440
4740
  if (beg == 0) beg = -3; /* should never happen */
4441
4741
  if (end == 0) end = -3;
4442
4742
  newtok(p);
4443
4743
  while ((c = nextc(p)) != end || nest_level != 0) {
4744
+ pos++;
4444
4745
  if (hinf && (c == '\n' || c < 0)) {
4445
4746
  mrb_bool line_head;
4446
4747
  tokadd(p, '\n');
@@ -4460,6 +4761,7 @@ parse_string(parser_state *p)
4460
4761
  }
4461
4762
  }
4462
4763
  if ((len-1 == hinf->term_len) && (strncmp(s, hinf->term, len-1) == 0)) {
4764
+ heredoc_remove_indent(p, hinf);
4463
4765
  return tHEREDOC_END;
4464
4766
  }
4465
4767
  }
@@ -4478,9 +4780,22 @@ parse_string(parser_state *p)
4478
4780
  }
4479
4781
  return 0;
4480
4782
  }
4481
- pylval.nd = new_str(p, tok(p), toklen(p));
4783
+ node *nd = new_str(p, tok(p), toklen(p));
4784
+ pylval.nd = nd;
4785
+ if (unindent && head) {
4786
+ nspaces = push(nspaces, nint(spaces));
4787
+ heredoc_push_indented(p, hinf, nd->cdr, escaped, nspaces, empty && line_head);
4788
+ }
4482
4789
  return tHD_STRING_MID;
4483
4790
  }
4791
+ if (unindent && empty) {
4792
+ if (c == '\t')
4793
+ spaces += 8;
4794
+ else if (ISSPACE(c))
4795
+ ++spaces;
4796
+ else
4797
+ empty = FALSE;
4798
+ }
4484
4799
  if (c < 0) {
4485
4800
  yyerror(p, "unterminated string meets end of file");
4486
4801
  return 0;
@@ -4502,6 +4817,13 @@ parse_string(parser_state *p)
4502
4817
  else if (c == '\n') {
4503
4818
  p->lineno++;
4504
4819
  p->column = 0;
4820
+ if (unindent) {
4821
+ nspaces = push(nspaces, nint(spaces));
4822
+ escaped = push(escaped, nint(pos));
4823
+ pos--;
4824
+ empty = TRUE;
4825
+ spaces = 0;
4826
+ }
4505
4827
  if (type & STR_FUNC_ARRAY) {
4506
4828
  tokadd(p, '\n');
4507
4829
  }
@@ -4551,8 +4873,13 @@ parse_string(parser_state *p)
4551
4873
  tokfix(p);
4552
4874
  p->lstate = EXPR_BEG;
4553
4875
  p->cmd_start = TRUE;
4554
- pylval.nd = new_str(p, tok(p), toklen(p));
4876
+ node *nd = new_str(p, tok(p), toklen(p));
4877
+ pylval.nd = nd;
4555
4878
  if (hinf) {
4879
+ if (unindent && head) {
4880
+ nspaces = push(nspaces, nint(spaces));
4881
+ heredoc_push_indented(p, hinf, nd->cdr, escaped, nspaces, FALSE);
4882
+ }
4556
4883
  hinf->line_head = FALSE;
4557
4884
  return tHD_STRING_PART;
4558
4885
  }
@@ -4673,7 +5000,7 @@ number_literal_suffix(parser_state *p)
4673
5000
  int mask = NUM_SUFFIX_R|NUM_SUFFIX_I;
4674
5001
 
4675
5002
  while ((c = nextc(p)) != -1) {
4676
- list = push(list, (node*)(intptr_t)c);
5003
+ list = push(list, nint(c));
4677
5004
 
4678
5005
  if ((mask & NUM_SUFFIX_I) && c == 'i') {
4679
5006
  result |= (mask & NUM_SUFFIX_I);
@@ -4690,7 +5017,7 @@ number_literal_suffix(parser_state *p)
4690
5017
  if (!ISASCII(c) || ISALPHA(c) || c == '_') {
4691
5018
  p->column = column;
4692
5019
  if (p->pb) {
4693
- p->pb = append((node*)list, p->pb);
5020
+ p->pb = append(list, p->pb);
4694
5021
  }
4695
5022
  else {
4696
5023
  p->pb = list;
@@ -4709,6 +5036,7 @@ heredoc_identifier(parser_state *p)
4709
5036
  int c;
4710
5037
  int type = str_heredoc;
4711
5038
  mrb_bool indent = FALSE;
5039
+ mrb_bool squiggly = FALSE;
4712
5040
  mrb_bool quote = FALSE;
4713
5041
  node *newnode;
4714
5042
  parser_heredoc_info *info;
@@ -4718,8 +5046,11 @@ heredoc_identifier(parser_state *p)
4718
5046
  pushback(p, c);
4719
5047
  return 0;
4720
5048
  }
4721
- if (c == '-') {
4722
- indent = TRUE;
5049
+ if (c == '-' || c == '~') {
5050
+ if (c == '-')
5051
+ indent = TRUE;
5052
+ if (c == '~')
5053
+ squiggly = TRUE;
4723
5054
  c = nextc(p);
4724
5055
  }
4725
5056
  if (c == '\'' || c == '"') {
@@ -4746,6 +5077,7 @@ heredoc_identifier(parser_state *p)
4746
5077
  if (! identchar(c)) {
4747
5078
  pushback(p, c);
4748
5079
  if (indent) pushback(p, '-');
5080
+ if (squiggly) pushback(p, '~');
4749
5081
  return 0;
4750
5082
  }
4751
5083
  newtok(p);
@@ -4762,7 +5094,10 @@ heredoc_identifier(parser_state *p)
4762
5094
  if (! quote)
4763
5095
  type |= STR_FUNC_EXPAND;
4764
5096
  info->type = (string_type)type;
4765
- info->allow_indent = indent;
5097
+ info->allow_indent = indent || squiggly;
5098
+ info->remove_indent = squiggly;
5099
+ info->indent = ~0U;
5100
+ info->indented = NULL;
4766
5101
  info->line_head = TRUE;
4767
5102
  info->doc = NULL;
4768
5103
  p->heredocs_from_nextline = push(p->heredocs_from_nextline, newnode);
@@ -4785,6 +5120,7 @@ static int
4785
5120
  parser_yylex(parser_state *p)
4786
5121
  {
4787
5122
  int32_t c;
5123
+ int nlines = 1;
4788
5124
  int space_seen = 0;
4789
5125
  int cmd_state;
4790
5126
  enum mrb_lex_state_enum last_state;
@@ -4842,6 +5178,7 @@ parser_yylex(parser_state *p)
4842
5178
  break;
4843
5179
  }
4844
5180
  if (p->parsing_heredoc != NULL) {
5181
+ pylval.num = nlines;
4845
5182
  return '\n';
4846
5183
  }
4847
5184
  while ((c = nextc(p))) {
@@ -4851,13 +5188,13 @@ parser_yylex(parser_state *p)
4851
5188
  space_seen = 1;
4852
5189
  break;
4853
5190
  case '#': /* comment as a whitespace */
4854
- pushback(p, '#');
4855
- p->lineno++;
4856
- goto retry;
5191
+ skip(p, '\n');
5192
+ nlines++;
5193
+ break;
4857
5194
  case '.':
4858
5195
  if (!peek(p, '.')) {
4859
5196
  pushback(p, '.');
4860
- p->lineno++;
5197
+ p->lineno+=nlines; nlines=1;
4861
5198
  goto retry;
4862
5199
  }
4863
5200
  pushback(p, c);
@@ -4865,7 +5202,7 @@ parser_yylex(parser_state *p)
4865
5202
  case '&':
4866
5203
  if (peek(p, '.')) {
4867
5204
  pushback(p, '&');
4868
- p->lineno++;
5205
+ p->lineno+=nlines; nlines=1;
4869
5206
  goto retry;
4870
5207
  }
4871
5208
  pushback(p, c);
@@ -4881,12 +5218,13 @@ parser_yylex(parser_state *p)
4881
5218
  normal_newline:
4882
5219
  p->cmd_start = TRUE;
4883
5220
  p->lstate = EXPR_BEG;
5221
+ pylval.num = nlines;
4884
5222
  return '\n';
4885
5223
 
4886
5224
  case '*':
4887
5225
  if ((c = nextc(p)) == '*') {
4888
5226
  if ((c = nextc(p)) == '=') {
4889
- pylval.id = intern_lit("**");
5227
+ pylval.id = intern_op(pow);
4890
5228
  p->lstate = EXPR_BEG;
4891
5229
  return tOP_ASGN;
4892
5230
  }
@@ -4904,7 +5242,7 @@ parser_yylex(parser_state *p)
4904
5242
  }
4905
5243
  else {
4906
5244
  if (c == '=') {
4907
- pylval.id = intern_lit("*");
5245
+ pylval.id = intern_op(mul);
4908
5246
  p->lstate = EXPR_BEG;
4909
5247
  return tOP_ASGN;
4910
5248
  }
@@ -4963,7 +5301,7 @@ parser_yylex(parser_state *p)
4963
5301
  c = nextc(p);
4964
5302
  } while (!(c < 0 || ISSPACE(c)));
4965
5303
  if (c != '\n') skip(p, '\n');
4966
- p->lineno++;
5304
+ p->lineno+=nlines; nlines=1;
4967
5305
  p->column = 0;
4968
5306
  goto retry;
4969
5307
  }
@@ -5020,7 +5358,7 @@ parser_yylex(parser_state *p)
5020
5358
  }
5021
5359
  if (c == '<') {
5022
5360
  if ((c = nextc(p)) == '=') {
5023
- pylval.id = intern_lit("<<");
5361
+ pylval.id = intern_op(lshift);
5024
5362
  p->lstate = EXPR_BEG;
5025
5363
  return tOP_ASGN;
5026
5364
  }
@@ -5042,7 +5380,7 @@ parser_yylex(parser_state *p)
5042
5380
  }
5043
5381
  if (c == '>') {
5044
5382
  if ((c = nextc(p)) == '=') {
5045
- pylval.id = intern_lit(">>");
5383
+ pylval.id = intern_op(rshift);
5046
5384
  p->lstate = EXPR_BEG;
5047
5385
  return tOP_ASGN;
5048
5386
  }
@@ -5150,7 +5488,7 @@ parser_yylex(parser_state *p)
5150
5488
  if ((c = nextc(p)) == '&') {
5151
5489
  p->lstate = EXPR_BEG;
5152
5490
  if ((c = nextc(p)) == '=') {
5153
- pylval.id = intern_lit("&&");
5491
+ pylval.id = intern_op(andand);
5154
5492
  p->lstate = EXPR_BEG;
5155
5493
  return tOP_ASGN;
5156
5494
  }
@@ -5162,7 +5500,7 @@ parser_yylex(parser_state *p)
5162
5500
  return tANDDOT;
5163
5501
  }
5164
5502
  else if (c == '=') {
5165
- pylval.id = intern_lit("&");
5503
+ pylval.id = intern_op(and);
5166
5504
  p->lstate = EXPR_BEG;
5167
5505
  return tOP_ASGN;
5168
5506
  }
@@ -5189,7 +5527,7 @@ parser_yylex(parser_state *p)
5189
5527
  if ((c = nextc(p)) == '|') {
5190
5528
  p->lstate = EXPR_BEG;
5191
5529
  if ((c = nextc(p)) == '=') {
5192
- pylval.id = intern_lit("||");
5530
+ pylval.id = intern_op(oror);
5193
5531
  p->lstate = EXPR_BEG;
5194
5532
  return tOP_ASGN;
5195
5533
  }
@@ -5197,7 +5535,7 @@ parser_yylex(parser_state *p)
5197
5535
  return tOROP;
5198
5536
  }
5199
5537
  if (c == '=') {
5200
- pylval.id = intern_lit("|");
5538
+ pylval.id = intern_op(or);
5201
5539
  p->lstate = EXPR_BEG;
5202
5540
  return tOP_ASGN;
5203
5541
  }
@@ -5221,7 +5559,7 @@ parser_yylex(parser_state *p)
5221
5559
  return '+';
5222
5560
  }
5223
5561
  if (c == '=') {
5224
- pylval.id = intern_lit("+");
5562
+ pylval.id = intern_op(add);
5225
5563
  p->lstate = EXPR_BEG;
5226
5564
  return tOP_ASGN;
5227
5565
  }
@@ -5249,7 +5587,7 @@ parser_yylex(parser_state *p)
5249
5587
  return '-';
5250
5588
  }
5251
5589
  if (c == '=') {
5252
- pylval.id = intern_lit("-");
5590
+ pylval.id = intern_op(sub);
5253
5591
  p->lstate = EXPR_BEG;
5254
5592
  return tOP_ASGN;
5255
5593
  }
@@ -5270,20 +5608,23 @@ parser_yylex(parser_state *p)
5270
5608
  return '-';
5271
5609
 
5272
5610
  case '.':
5273
- p->lstate = EXPR_BEG;
5274
- if ((c = nextc(p)) == '.') {
5611
+ {
5612
+ int is_beg = IS_BEG();
5613
+ p->lstate = EXPR_BEG;
5275
5614
  if ((c = nextc(p)) == '.') {
5276
- return tDOT3;
5615
+ if ((c = nextc(p)) == '.') {
5616
+ return is_beg ? tBDOT3 : tDOT3;
5617
+ }
5618
+ pushback(p, c);
5619
+ return is_beg ? tBDOT2 : tDOT2;
5277
5620
  }
5278
5621
  pushback(p, c);
5279
- return tDOT2;
5280
- }
5281
- pushback(p, c);
5282
- if (c >= 0 && ISDIGIT(c)) {
5283
- yyerror(p, "no .<digit> floating literal anymore; put 0 before dot");
5622
+ if (c >= 0 && ISDIGIT(c)) {
5623
+ yyerror(p, "no .<digit> floating literal anymore; put 0 before dot");
5624
+ }
5625
+ p->lstate = EXPR_DOT;
5626
+ return '.';
5284
5627
  }
5285
- p->lstate = EXPR_DOT;
5286
- return '.';
5287
5628
 
5288
5629
  start_num:
5289
5630
  case '0': case '1': case '2': case '3': case '4':
@@ -5499,7 +5840,7 @@ parser_yylex(parser_state *p)
5499
5840
  }
5500
5841
  tokfix(p);
5501
5842
  if (is_float) {
5502
- #ifdef MRB_WITHOUT_FLOAT
5843
+ #ifdef MRB_NO_FLOAT
5503
5844
  yywarning_s(p, "floating point numbers are not supported", tok(p));
5504
5845
  pylval.nd = new_int(p, "0", 10, 0);
5505
5846
  return tINTEGER;
@@ -5517,6 +5858,10 @@ parser_yylex(parser_state *p)
5517
5858
  errno = 0;
5518
5859
  }
5519
5860
  suffix = number_literal_suffix(p);
5861
+ if (seen_e && (suffix & NUM_SUFFIX_R)) {
5862
+ pushback(p, 'r');
5863
+ suffix &= ~NUM_SUFFIX_R;
5864
+ }
5520
5865
  pylval.nd = new_float(p, tok(p), suffix);
5521
5866
  return tFLOAT;
5522
5867
  #endif
@@ -5554,14 +5899,14 @@ parser_yylex(parser_state *p)
5554
5899
  p->lstate = EXPR_BEG;
5555
5900
  return tLABEL_TAG;
5556
5901
  }
5557
- if (!ISSPACE(c) || IS_BEG()) {
5902
+ if (IS_END() || ISSPACE(c) || c == '#') {
5558
5903
  pushback(p, c);
5559
- p->lstate = EXPR_FNAME;
5560
- return tSYMBEG;
5904
+ p->lstate = EXPR_BEG;
5905
+ return ':';
5561
5906
  }
5562
5907
  pushback(p, c);
5563
- p->lstate = EXPR_BEG;
5564
- return ':';
5908
+ p->lstate = EXPR_FNAME;
5909
+ return tSYMBEG;
5565
5910
 
5566
5911
  case '/':
5567
5912
  if (IS_BEG()) {
@@ -5569,7 +5914,7 @@ parser_yylex(parser_state *p)
5569
5914
  return tREGEXP_BEG;
5570
5915
  }
5571
5916
  if ((c = nextc(p)) == '=') {
5572
- pylval.id = intern_lit("/");
5917
+ pylval.id = intern_op(div);
5573
5918
  p->lstate = EXPR_BEG;
5574
5919
  return tOP_ASGN;
5575
5920
  }
@@ -5588,7 +5933,7 @@ parser_yylex(parser_state *p)
5588
5933
 
5589
5934
  case '^':
5590
5935
  if ((c = nextc(p)) == '=') {
5591
- pylval.id = intern_lit("^");
5936
+ pylval.id = intern_op(xor);
5592
5937
  p->lstate = EXPR_BEG;
5593
5938
  return tOP_ASGN;
5594
5939
  }
@@ -5641,6 +5986,7 @@ parser_yylex(parser_state *p)
5641
5986
  p->paren_nest++;
5642
5987
  if (p->lstate == EXPR_FNAME || p->lstate == EXPR_DOT) {
5643
5988
  p->lstate = EXPR_ARG;
5989
+ p->paren_nest--;
5644
5990
  if ((c = nextc(p)) == ']') {
5645
5991
  if ((c = nextc(p)) == '=') {
5646
5992
  return tASET;
@@ -5685,7 +6031,7 @@ parser_yylex(parser_state *p)
5685
6031
  case '\\':
5686
6032
  c = nextc(p);
5687
6033
  if (c == '\n') {
5688
- p->lineno++;
6034
+ p->lineno+=nlines; nlines=1;
5689
6035
  p->column = 0;
5690
6036
  space_seen = 1;
5691
6037
  goto retry; /* skip \\n */
@@ -5765,7 +6111,7 @@ parser_yylex(parser_state *p)
5765
6111
  }
5766
6112
  }
5767
6113
  if ((c = nextc(p)) == '=') {
5768
- pylval.id = intern_lit("%");
6114
+ pylval.id = intern_op(mod);
5769
6115
  p->lstate = EXPR_BEG;
5770
6116
  return tOP_ASGN;
5771
6117
  }
@@ -5968,7 +6314,7 @@ parser_yylex(parser_state *p)
5968
6314
  break;
5969
6315
 
5970
6316
  case '_':
5971
- if (toklen(p) == 2 && ISDIGIT(tok(p)[1]) && p->nvars) {
6317
+ if (p->lstate != EXPR_FNAME && toklen(p) == 2 && ISDIGIT(tok(p)[1]) && p->nvars) {
5972
6318
  int n = tok(p)[1] - '0';
5973
6319
  int nvar;
5974
6320
 
@@ -6130,7 +6476,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt)
6130
6476
  }
6131
6477
  p->capture_errors = cxt->capture_errors;
6132
6478
  p->no_optimize = cxt->no_optimize;
6133
- p->on_eval = cxt->on_eval;
6479
+ p->upper = cxt->upper;
6134
6480
  if (cxt->partial_hook) {
6135
6481
  p->cxt = cxt;
6136
6482
  }
@@ -6229,7 +6575,7 @@ mrb_parser_new(mrb_state *mrb)
6229
6575
  p->pool = pool;
6230
6576
 
6231
6577
  p->s = p->send = NULL;
6232
- #ifndef MRB_DISABLE_STDIO
6578
+ #ifndef MRB_NO_STDIO
6233
6579
  p->f = NULL;
6234
6580
  #endif
6235
6581
 
@@ -6301,11 +6647,21 @@ mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*func)(struct mrb_parser
6301
6647
  c->partial_data = data;
6302
6648
  }
6303
6649
 
6650
+ MRB_API void
6651
+ mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c)
6652
+ {
6653
+ if (c->syms) {
6654
+ mrb_free(mrb, c->syms);
6655
+ c->syms = NULL;
6656
+ c->slen = 0;
6657
+ }
6658
+ }
6659
+
6304
6660
  MRB_API void
6305
6661
  mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
6306
6662
  {
6307
6663
  mrb_sym sym;
6308
- size_t i;
6664
+ uint16_t i;
6309
6665
  mrb_sym* new_table;
6310
6666
 
6311
6667
  sym = mrb_intern_cstr(p->mrb, f);
@@ -6314,7 +6670,7 @@ mrb_parser_set_filename(struct mrb_parser_state *p, const char *f)
6314
6670
 
6315
6671
  for (i = 0; i < p->filename_table_length; ++i) {
6316
6672
  if (p->filename_table[i] == sym) {
6317
- p->current_filename_index = (int)i;
6673
+ p->current_filename_index = i;
6318
6674
  return;
6319
6675
  }
6320
6676
  }
@@ -6341,20 +6697,32 @@ mrb_parser_get_filename(struct mrb_parser_state* p, uint16_t idx) {
6341
6697
  }
6342
6698
  }
6343
6699
 
6344
- #ifndef MRB_DISABLE_STDIO
6345
- MRB_API parser_state*
6346
- mrb_parse_file(mrb_state *mrb, FILE *f, mrbc_context *c)
6700
+ #ifndef MRB_NO_STDIO
6701
+ static struct mrb_parser_state *
6702
+ mrb_parse_file_continue(mrb_state *mrb, FILE *f, const void *prebuf, size_t prebufsize, mrbc_context *c)
6347
6703
  {
6348
6704
  parser_state *p;
6349
6705
 
6350
6706
  p = mrb_parser_new(mrb);
6351
6707
  if (!p) return NULL;
6352
- p->s = p->send = NULL;
6708
+ if (prebuf) {
6709
+ p->s = (const char *)prebuf;
6710
+ p->send = (const char *)prebuf + prebufsize;
6711
+ }
6712
+ else {
6713
+ p->s = p->send = NULL;
6714
+ }
6353
6715
  p->f = f;
6354
6716
 
6355
6717
  mrb_parser_parse(p, c);
6356
6718
  return p;
6357
6719
  }
6720
+
6721
+ MRB_API parser_state*
6722
+ mrb_parse_file(mrb_state *mrb, FILE *f, mrbc_context *c)
6723
+ {
6724
+ return mrb_parse_file_continue(mrb, f, NULL, 0, c);
6725
+ }
6358
6726
  #endif
6359
6727
 
6360
6728
  MRB_API parser_state*
@@ -6383,7 +6751,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
6383
6751
  struct RClass *target = mrb->object_class;
6384
6752
  struct RProc *proc;
6385
6753
  mrb_value v;
6386
- unsigned int keep = 0;
6754
+ mrb_int keep = 0;
6387
6755
 
6388
6756
  if (!p) {
6389
6757
  return mrb_undef_value();
@@ -6403,7 +6771,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
6403
6771
  }
6404
6772
  else {
6405
6773
  if (mrb->exc == NULL) {
6406
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
6774
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
6407
6775
  }
6408
6776
  mrb_parser_free(p);
6409
6777
  return mrb_undef_value();
@@ -6413,7 +6781,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
6413
6781
  mrb_parser_free(p);
6414
6782
  if (proc == NULL) {
6415
6783
  if (mrb->exc == NULL) {
6416
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
6784
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
6417
6785
  }
6418
6786
  return mrb_undef_value();
6419
6787
  }
@@ -6432,14 +6800,14 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
6432
6800
  }
6433
6801
  MRB_PROC_SET_TARGET_CLASS(proc, target);
6434
6802
  if (mrb->c->ci) {
6435
- mrb->c->ci->target_class = target;
6803
+ mrb_vm_ci_target_class_set(mrb->c->ci, target);
6436
6804
  }
6437
6805
  v = mrb_top_run(mrb, proc, mrb_top_self(mrb), keep);
6438
6806
  if (mrb->exc) return mrb_nil_value();
6439
6807
  return v;
6440
6808
  }
6441
6809
 
6442
- #ifndef MRB_DISABLE_STDIO
6810
+ #ifndef MRB_NO_STDIO
6443
6811
  MRB_API mrb_value
6444
6812
  mrb_load_file_cxt(mrb_state *mrb, FILE *f, mrbc_context *c)
6445
6813
  {
@@ -6451,6 +6819,55 @@ mrb_load_file(mrb_state *mrb, FILE *f)
6451
6819
  {
6452
6820
  return mrb_load_file_cxt(mrb, f, NULL);
6453
6821
  }
6822
+
6823
+ #define DETECT_SIZE 64
6824
+
6825
+ /*
6826
+ * In order to be recognized as a `.mrb` file, the following three points must be satisfied:
6827
+ * - File starts with "RITE"
6828
+ * - At least `sizeof(struct rite_binary_header)` bytes can be read
6829
+ * - `NUL` is included in the first 64 bytes of the file
6830
+ */
6831
+ MRB_API mrb_value
6832
+ mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrbc_context *c)
6833
+ {
6834
+ union {
6835
+ char b[DETECT_SIZE];
6836
+ struct rite_binary_header h;
6837
+ } leading;
6838
+ size_t bufsize;
6839
+
6840
+ if (mrb == NULL || fp == NULL) {
6841
+ return mrb_nil_value();
6842
+ }
6843
+
6844
+ bufsize = fread(leading.b, sizeof(char), sizeof(leading), fp);
6845
+ if (bufsize < sizeof(leading.h) ||
6846
+ memcmp(leading.h.binary_ident, RITE_BINARY_IDENT, sizeof(leading.h.binary_ident)) != 0 ||
6847
+ memchr(leading.b, '\0', bufsize) == NULL) {
6848
+ return mrb_load_exec(mrb, mrb_parse_file_continue(mrb, fp, leading.b, bufsize, c), c);
6849
+ }
6850
+ else {
6851
+ size_t binsize;
6852
+ uint8_t *bin;
6853
+ mrb_value bin_obj = mrb_nil_value(); /* temporary string object */
6854
+ mrb_value result;
6855
+
6856
+ binsize = bin_to_uint32(leading.h.binary_size);
6857
+ bin_obj = mrb_str_new(mrb, NULL, binsize);
6858
+ bin = (uint8_t *)RSTRING_PTR(bin_obj);
6859
+ memcpy(bin, leading.b, bufsize);
6860
+ if (binsize > bufsize &&
6861
+ fread(bin + bufsize, binsize - bufsize, 1, fp) == 0) {
6862
+ binsize = bufsize;
6863
+ /* The error is reported by mrb_load_irep_buf_cxt() */
6864
+ }
6865
+
6866
+ result = mrb_load_irep_buf_cxt(mrb, bin, binsize, c);
6867
+ if (mrb_string_p(bin_obj)) mrb_str_resize(mrb, bin_obj, 0);
6868
+ return result;
6869
+ }
6870
+ }
6454
6871
  #endif
6455
6872
 
6456
6873
  MRB_API mrb_value
@@ -6477,7 +6894,7 @@ mrb_load_string(mrb_state *mrb, const char *s)
6477
6894
  return mrb_load_string_cxt(mrb, s, NULL);
6478
6895
  }
6479
6896
 
6480
- #ifndef MRB_DISABLE_STDIO
6897
+ #ifndef MRB_NO_STDIO
6481
6898
 
6482
6899
  static void
6483
6900
  dump_prefix(node *tree, int offset)
@@ -6549,10 +6966,10 @@ dump_args(mrb_state *mrb, node *n, int offset)
6549
6966
  static const char*
6550
6967
  str_dump(mrb_state *mrb, const char *str, int len)
6551
6968
  {
6552
- mrb_int ai = mrb_gc_arena_save(mrb);
6969
+ int ai = mrb_gc_arena_save(mrb);
6553
6970
  mrb_value s;
6554
6971
  # if INT_MAX > MRB_INT_MAX / 4
6555
- /* check maximum length with "\xNN" charactor */
6972
+ /* check maximum length with "\xNN" character */
6556
6973
  if (len > MRB_INT_MAX / 4) {
6557
6974
  len = MRB_INT_MAX / 4;
6558
6975
  }
@@ -6567,7 +6984,7 @@ str_dump(mrb_state *mrb, const char *str, int len)
6567
6984
  void
6568
6985
  mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
6569
6986
  {
6570
- #ifndef MRB_DISABLE_STDIO
6987
+ #ifndef MRB_NO_STDIO
6571
6988
  int nodetype;
6572
6989
 
6573
6990
  if (!tree) return;
@@ -6894,7 +7311,7 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
6894
7311
  if (n2->car) {
6895
7312
  dump_prefix(n2, offset+2);
6896
7313
  printf("rest:\n");
6897
- if (n2->car == (node*)-1) {
7314
+ if (n2->car == nint(-1)) {
6898
7315
  dump_prefix(n2, offset+2);
6899
7316
  printf("(empty)\n");
6900
7317
  }
@@ -7136,11 +7553,11 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
7136
7553
 
7137
7554
  case NODE_CLASS:
7138
7555
  printf("NODE_CLASS:\n");
7139
- if (tree->car->car == (node*)0) {
7556
+ if (tree->car->car == nint(0)) {
7140
7557
  dump_prefix(tree, offset+1);
7141
7558
  printf(":%s\n", mrb_sym_name(mrb, sym(tree->car->cdr)));
7142
7559
  }
7143
- else if (tree->car->car == (node*)1) {
7560
+ else if (tree->car->car == nint(1)) {
7144
7561
  dump_prefix(tree, offset+1);
7145
7562
  printf("::%s\n", mrb_sym_name(mrb, sym(tree->car->cdr)));
7146
7563
  }
@@ -7161,11 +7578,11 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
7161
7578
 
7162
7579
  case NODE_MODULE:
7163
7580
  printf("NODE_MODULE:\n");
7164
- if (tree->car->car == (node*)0) {
7581
+ if (tree->car->car == nint(0)) {
7165
7582
  dump_prefix(tree, offset+1);
7166
7583
  printf(":%s\n", mrb_sym_name(mrb, sym(tree->car->cdr)));
7167
7584
  }
7168
- else if (tree->car->car == (node*)1) {
7585
+ else if (tree->car->car == nint(1)) {
7169
7586
  dump_prefix(tree, offset+1);
7170
7587
  printf("::%s\n", mrb_sym_name(mrb, sym(tree->car->cdr)));
7171
7588
  }