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
@@ -51,12 +51,12 @@ select_line_type(const uint16_t *lines, size_t lines_len)
51
51
  }
52
52
 
53
53
  MRB_API char const*
54
- mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc)
54
+ mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
55
55
  {
56
- if (irep && pc >= 0 && pc < irep->ilen) {
56
+ if (irep && pc < irep->ilen) {
57
57
  mrb_irep_debug_info_file* f = NULL;
58
58
  if (!irep->debug_info) return NULL;
59
- else if ((f = get_file(irep->debug_info, (uint32_t)pc))) {
59
+ else if ((f = get_file(irep->debug_info, pc))) {
60
60
  return mrb_sym_name_len(mrb, f->filename_sym, NULL);
61
61
  }
62
62
  }
@@ -64,14 +64,14 @@ mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc)
64
64
  }
65
65
 
66
66
  MRB_API int32_t
67
- mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc)
67
+ mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
68
68
  {
69
- if (irep && pc >= 0 && pc < irep->ilen) {
69
+ if (irep && pc < irep->ilen) {
70
70
  mrb_irep_debug_info_file* f = NULL;
71
71
  if (!irep->debug_info) {
72
72
  return -1;
73
73
  }
74
- else if ((f = get_file(irep->debug_info, (uint32_t)pc))) {
74
+ else if ((f = get_file(irep->debug_info, pc))) {
75
75
  switch (f->line_type) {
76
76
  case mrb_debug_line_ary:
77
77
  mrb_assert(f->start_pos <= pc && pc < (f->start_pos + f->line_entry_count));
@@ -204,11 +204,14 @@ mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d)
204
204
 
205
205
  if (!d) { return; }
206
206
 
207
- for (i = 0; i < d->flen; ++i) {
208
- mrb_assert(d->files[i]);
209
- mrb_free(mrb, d->files[i]->lines.ptr);
210
- mrb_free(mrb, d->files[i]);
207
+ if (d->files) {
208
+ for (i = 0; i < d->flen; ++i) {
209
+ if (d->files[i]) {
210
+ mrb_free(mrb, d->files[i]->lines.ptr);
211
+ mrb_free(mrb, d->files[i]);
212
+ }
213
+ }
214
+ mrb_free(mrb, d->files);
211
215
  }
212
- mrb_free(mrb, d->files);
213
216
  mrb_free(mrb, d);
214
217
  }
@@ -10,36 +10,57 @@
10
10
  #include <mruby/dump.h>
11
11
  #include <mruby/string.h>
12
12
  #include <mruby/irep.h>
13
- #include <mruby/numeric.h>
14
13
  #include <mruby/debug.h>
15
14
 
16
- #define FLAG_BYTEORDER_NATIVE 2
17
- #define FLAG_BYTEORDER_NONATIVE 0
18
-
19
- #ifndef MRB_WITHOUT_FLOAT
20
- #ifdef MRB_USE_FLOAT
21
- #define MRB_FLOAT_FMT "%.9g"
22
- #else
15
+ #ifndef MRB_NO_FLOAT
16
+ #include <mruby/endian.h>
23
17
  #define MRB_FLOAT_FMT "%.17g"
24
18
  #endif
25
- #endif
26
19
 
27
- static size_t get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep);
20
+ static size_t get_irep_record_size_1(mrb_state *mrb, const mrb_irep *irep);
28
21
 
29
22
  #if UINT32_MAX > SIZE_MAX
30
23
  # error This code cannot be built on your environment.
31
24
  #endif
32
25
 
33
- static size_t
34
- write_padding(uint8_t *buf)
35
- {
36
- const size_t align = MRB_DUMP_ALIGNMENT;
37
- size_t pad_len = -(intptr_t)buf & (align-1);
38
- if (pad_len > 0) {
39
- memset(buf, 0, pad_len);
40
- }
41
- return pad_len;
42
- }
26
+ #define OPERATOR_SYMBOL(sym_name, name) {name, sym_name, sizeof(sym_name)-1}
27
+ struct operator_symbol {
28
+ const char *name;
29
+ const char *sym_name;
30
+ uint16_t sym_name_len;
31
+ };
32
+ static const struct operator_symbol operator_table[] = {
33
+ OPERATOR_SYMBOL("!", "not"),
34
+ OPERATOR_SYMBOL("%", "mod"),
35
+ OPERATOR_SYMBOL("&", "and"),
36
+ OPERATOR_SYMBOL("*", "mul"),
37
+ OPERATOR_SYMBOL("+", "add"),
38
+ OPERATOR_SYMBOL("-", "sub"),
39
+ OPERATOR_SYMBOL("/", "div"),
40
+ OPERATOR_SYMBOL("<", "lt"),
41
+ OPERATOR_SYMBOL(">", "gt"),
42
+ OPERATOR_SYMBOL("^", "xor"),
43
+ OPERATOR_SYMBOL("`", "tick"),
44
+ OPERATOR_SYMBOL("|", "or"),
45
+ OPERATOR_SYMBOL("~", "neg"),
46
+ OPERATOR_SYMBOL("!=", "neq"),
47
+ OPERATOR_SYMBOL("!~", "nmatch"),
48
+ OPERATOR_SYMBOL("&&", "andand"),
49
+ OPERATOR_SYMBOL("**", "pow"),
50
+ OPERATOR_SYMBOL("+@", "plus"),
51
+ OPERATOR_SYMBOL("-@", "minus"),
52
+ OPERATOR_SYMBOL("<<", "lshift"),
53
+ OPERATOR_SYMBOL("<=", "le"),
54
+ OPERATOR_SYMBOL("==", "eq"),
55
+ OPERATOR_SYMBOL("=~", "match"),
56
+ OPERATOR_SYMBOL(">=", "ge"),
57
+ OPERATOR_SYMBOL(">>", "rshift"),
58
+ OPERATOR_SYMBOL("[]", "aref"),
59
+ OPERATOR_SYMBOL("||", "oror"),
60
+ OPERATOR_SYMBOL("<=>", "cmp"),
61
+ OPERATOR_SYMBOL("===", "eqq"),
62
+ OPERATOR_SYMBOL("[]=", "aset"),
63
+ };
43
64
 
44
65
  static size_t
45
66
  get_irep_header_size(mrb_state *mrb)
@@ -53,7 +74,7 @@ get_irep_header_size(mrb_state *mrb)
53
74
  }
54
75
 
55
76
  static ptrdiff_t
56
- write_irep_header(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
77
+ write_irep_header(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
57
78
  {
58
79
  uint8_t *cur = buf;
59
80
 
@@ -65,89 +86,104 @@ write_irep_header(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
65
86
  return cur - buf;
66
87
  }
67
88
 
68
-
69
89
  static size_t
70
- get_iseq_block_size(mrb_state *mrb, mrb_irep *irep)
90
+ get_iseq_block_size(mrb_state *mrb, const mrb_irep *irep)
71
91
  {
72
92
  size_t size = 0;
73
93
 
74
- size += sizeof(uint32_t); /* ilen */
75
- size += sizeof(uint32_t); /* max padding */
76
- size += sizeof(uint32_t) * irep->ilen; /* iseq(n) */
94
+ size += sizeof(uint16_t); /* clen */
95
+ size += sizeof(uint16_t); /* ilen */
96
+ size += irep->ilen * sizeof(mrb_code); /* iseq(n) */
97
+ size += irep->clen * sizeof(struct mrb_irep_catch_handler);
77
98
 
78
99
  return size;
79
100
  }
80
101
 
81
102
  static ptrdiff_t
82
- write_iseq_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf, uint8_t flags)
103
+ write_iseq_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf, uint8_t flags)
83
104
  {
84
105
  uint8_t *cur = buf;
106
+ size_t seqlen = irep->ilen * sizeof(mrb_code) +
107
+ irep->clen * sizeof(struct mrb_irep_catch_handler);
85
108
 
86
- cur += uint32_to_bin(irep->ilen, cur); /* number of opcode */
87
- cur += write_padding(cur);
88
- memcpy(cur, irep->iseq, irep->ilen * sizeof(mrb_code));
89
- cur += irep->ilen * sizeof(mrb_code);
109
+ cur += uint16_to_bin(irep->clen, cur); /* number of catch handlers */
110
+ cur += uint16_to_bin(irep->ilen, cur); /* number of opcode */
111
+ memcpy(cur, irep->iseq, seqlen);
112
+ cur += seqlen;
90
113
 
91
114
  return cur - buf;
92
115
  }
93
116
 
94
- #ifndef MRB_WITHOUT_FLOAT
95
- static mrb_value
96
- float_to_str(mrb_state *mrb, mrb_value flt)
117
+ #ifndef MRB_NO_FLOAT
118
+ static void
119
+ dump_float(mrb_state *mrb, uint8_t *buf, mrb_float f)
97
120
  {
98
- mrb_float f = mrb_float(flt);
121
+ /* dump IEEE754 binary in little endian */
122
+ union {
123
+ double f;
124
+ char s[sizeof(double)];
125
+ } u = {.f = (double)f};
126
+
127
+ if (littleendian) {
128
+ memcpy(buf, u.s, sizeof(double));
129
+ }
130
+ else {
131
+ size_t i;
99
132
 
100
- if (isinf(f)) {
101
- return f < 0 ? mrb_str_new_lit(mrb, "I") : mrb_str_new_lit(mrb, "i");
133
+ for (i=0; i<sizeof(double); i++) {
134
+ buf[i] = u.s[sizeof(double)-i-1];
135
+ }
102
136
  }
103
- return mrb_float_to_str(mrb, flt, MRB_FLOAT_FMT);
104
137
  }
105
138
  #endif
106
139
 
107
140
  static size_t
108
- get_pool_block_size(mrb_state *mrb, mrb_irep *irep)
141
+ get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
109
142
  {
110
143
  int pool_no;
111
144
  size_t size = 0;
112
- mrb_value str;
113
145
 
114
- size += sizeof(uint32_t); /* plen */
115
- size += irep->plen * (sizeof(uint8_t) + sizeof(uint16_t)); /* len(n) */
146
+ size += sizeof(uint16_t); /* plen */
147
+ size += irep->plen * sizeof(uint8_t); /* len(n) */
116
148
 
117
149
  for (pool_no = 0; pool_no < irep->plen; pool_no++) {
118
150
  int ai = mrb_gc_arena_save(mrb);
119
151
 
120
- switch (mrb_type(irep->pool[pool_no])) {
121
- case MRB_TT_FIXNUM:
122
- str = mrb_fixnum_to_str(mrb, irep->pool[pool_no], 10);
152
+ switch (irep->pool[pool_no].tt) {
153
+ case IREP_TT_INT64:
154
+ #ifdef MRB_64BIT
123
155
  {
124
- mrb_int len = RSTRING_LEN(str);
125
- mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
126
- size += (size_t)len;
156
+ int64_t i = irep->pool[pool_no].u.i64;
157
+
158
+ if (i < INT32_MIN || INT32_MAX < i)
159
+ size += 8;
160
+ else
161
+ size += 4;
127
162
  }
128
163
  break;
164
+ #else
165
+ /* fall through */
166
+ #endif
167
+ case IREP_TT_INT32:
168
+ size += 4; /* 32bits = 4bytes */
169
+ break;
129
170
 
130
- #ifndef MRB_WITHOUT_FLOAT
131
- case MRB_TT_FLOAT:
132
- str = float_to_str(mrb, irep->pool[pool_no]);
171
+ case IREP_TT_FLOAT:
172
+ #ifndef MRB_NO_FLOAT
133
173
  {
134
- mrb_int len = RSTRING_LEN(str);
135
- mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
136
- size += (size_t)len;
174
+ size += sizeof(double);
137
175
  }
138
- break;
139
176
  #endif
177
+ break;
140
178
 
141
- case MRB_TT_STRING:
179
+ default: /* packed IREP_TT_STRING */
142
180
  {
143
- mrb_int len = RSTRING_LEN(irep->pool[pool_no]);
181
+ mrb_int len = irep->pool[pool_no].tt >> 2; /* unpack length */
144
182
  mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
145
- size += (size_t)len;
183
+ size += sizeof(uint16_t);
184
+ size += (size_t)len+1;
146
185
  }
147
186
  break;
148
-
149
- default:
150
- break;
151
187
  }
152
188
  mrb_gc_arena_restore(mrb, ai);
153
189
  }
@@ -156,52 +192,63 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep)
156
192
  }
157
193
 
158
194
  static ptrdiff_t
159
- write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
195
+ write_pool_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
160
196
  {
161
197
  int pool_no;
162
198
  uint8_t *cur = buf;
163
- uint16_t len;
164
- mrb_value str;
165
- const char *char_ptr;
199
+ mrb_int len;
200
+ const char *ptr;
166
201
 
167
- cur += uint32_to_bin(irep->plen, cur); /* number of pool */
202
+ cur += uint16_to_bin(irep->plen, cur); /* number of pool */
168
203
 
169
204
  for (pool_no = 0; pool_no < irep->plen; pool_no++) {
170
205
  int ai = mrb_gc_arena_save(mrb);
171
206
 
172
- switch (mrb_type(irep->pool[pool_no])) {
173
- case MRB_TT_FIXNUM:
174
- cur += uint8_to_bin(IREP_TT_FIXNUM, cur); /* data type */
175
- str = mrb_fixnum_to_str(mrb, irep->pool[pool_no], 10);
207
+ switch (irep->pool[pool_no].tt) {
208
+ #ifdef MRB_64BIT
209
+ case IREP_TT_INT64:
210
+ {
211
+ int64_t i = irep->pool[pool_no].u.i64;
212
+ if (i < INT32_MIN || INT32_MAX < i) {
213
+ cur += uint8_to_bin(IREP_TT_INT64, cur); /* data type */
214
+ cur += uint32_to_bin((uint32_t)((i>>32) & 0xffffffff), cur); /* i64 hi */
215
+ cur += uint32_to_bin((uint32_t)((i ) & 0xffffffff), cur); /* i64 lo */
216
+ }
217
+ else {
218
+ cur += uint8_to_bin(IREP_TT_INT32, cur); /* data type */
219
+ cur += uint32_to_bin(irep->pool[pool_no].u.i32, cur); /* i32 */
220
+ }
221
+ }
222
+ break;
223
+ #endif
224
+ case IREP_TT_INT32:
225
+ cur += uint8_to_bin(IREP_TT_INT32, cur); /* data type */
226
+ cur += uint32_to_bin(irep->pool[pool_no].u.i32, cur); /* i32 */
176
227
  break;
177
228
 
178
- #ifndef MRB_WITHOUT_FLOAT
179
- case MRB_TT_FLOAT:
229
+ case IREP_TT_FLOAT:
180
230
  cur += uint8_to_bin(IREP_TT_FLOAT, cur); /* data type */
181
- str = float_to_str(mrb, irep->pool[pool_no]);
182
- break;
231
+ #ifndef MRB_NO_FLOAT
232
+ {
233
+ dump_float(mrb, cur,irep->pool[pool_no].u.f);
234
+ cur += sizeof(double);
235
+ }
236
+ #else
237
+ cur += uint16_to_bin(0, cur); /* zero length */
183
238
  #endif
184
-
185
- case MRB_TT_STRING:
186
- cur += uint8_to_bin(IREP_TT_STRING, cur); /* data type */
187
- str = irep->pool[pool_no];
188
239
  break;
189
240
 
190
- default:
191
- continue;
192
- }
193
-
194
- char_ptr = RSTRING_PTR(str);
195
- {
196
- mrb_int tlen = RSTRING_LEN(str);
197
- mrb_assert_int_fit(mrb_int, tlen, uint16_t, UINT16_MAX);
198
- len = (uint16_t)tlen;
241
+ default: /* string */
242
+ cur += uint8_to_bin(IREP_TT_STR, cur); /* data type */
243
+ ptr = irep->pool[pool_no].u.str;
244
+ len = irep->pool[pool_no].tt>>2;
245
+ mrb_assert_int_fit(mrb_int, len, uint16_t, UINT16_MAX);
246
+ cur += uint16_to_bin((uint16_t)len, cur); /* data length */
247
+ memcpy(cur, ptr, (size_t)len);
248
+ cur += len;
249
+ *cur++ = '\0';
250
+ break;
199
251
  }
200
-
201
- cur += uint16_to_bin(len, cur); /* data length */
202
- memcpy(cur, char_ptr, (size_t)len);
203
- cur += len;
204
-
205
252
  mrb_gc_arena_restore(mrb, ai);
206
253
  }
207
254
 
@@ -210,13 +257,13 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
210
257
 
211
258
 
212
259
  static size_t
213
- get_syms_block_size(mrb_state *mrb, mrb_irep *irep)
260
+ get_syms_block_size(mrb_state *mrb, const mrb_irep *irep)
214
261
  {
215
262
  size_t size = 0;
216
263
  int sym_no;
217
264
  mrb_int len;
218
265
 
219
- size += sizeof(uint32_t); /* slen */
266
+ size += sizeof(uint16_t); /* slen */
220
267
  for (sym_no = 0; sym_no < irep->slen; sym_no++) {
221
268
  size += sizeof(uint16_t); /* snl(n) */
222
269
  if (irep->syms[sym_no] != 0) {
@@ -229,13 +276,13 @@ get_syms_block_size(mrb_state *mrb, mrb_irep *irep)
229
276
  }
230
277
 
231
278
  static ptrdiff_t
232
- write_syms_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
279
+ write_syms_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
233
280
  {
234
281
  int sym_no;
235
282
  uint8_t *cur = buf;
236
283
  const char *name;
237
284
 
238
- cur += uint32_to_bin(irep->slen, cur); /* number of symbol */
285
+ cur += uint16_to_bin(irep->slen, cur); /* number of symbol */
239
286
 
240
287
  for (sym_no = 0; sym_no < irep->slen; sym_no++) {
241
288
  if (irep->syms[sym_no] != 0) {
@@ -258,7 +305,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
258
305
  }
259
306
 
260
307
  static size_t
261
- get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep)
308
+ get_irep_record_size_1(mrb_state *mrb, const mrb_irep *irep)
262
309
  {
263
310
  size_t size = 0;
264
311
 
@@ -270,7 +317,7 @@ get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep)
270
317
  }
271
318
 
272
319
  static size_t
273
- get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
320
+ get_irep_record_size(mrb_state *mrb, const mrb_irep *irep)
274
321
  {
275
322
  size_t size = 0;
276
323
  int irep_no;
@@ -283,7 +330,7 @@ get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
283
330
  }
284
331
 
285
332
  static int
286
- write_irep_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *irep_record_size, uint8_t flags)
333
+ write_irep_record(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *irep_record_size, uint8_t flags)
287
334
  {
288
335
  int i;
289
336
  uint8_t *src = bin;
@@ -292,11 +339,6 @@ write_irep_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *irep_rec
292
339
  return MRB_DUMP_INVALID_IREP;
293
340
  }
294
341
 
295
- *irep_record_size = get_irep_record_size_1(mrb, irep);
296
- if (*irep_record_size == 0) {
297
- return MRB_DUMP_GENERAL_FAILURE;
298
- }
299
-
300
342
  bin += write_irep_header(mrb, irep, bin);
301
343
  bin += write_iseq_block(mrb, irep, bin, flags);
302
344
  bin += write_pool_block(mrb, irep, bin);
@@ -344,7 +386,7 @@ write_section_irep_header(mrb_state *mrb, size_t section_size, uint8_t *bin)
344
386
  }
345
387
 
346
388
  static int
347
- write_section_irep(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *len_p, uint8_t flags)
389
+ write_section_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *len_p, uint8_t flags)
348
390
  {
349
391
  int result;
350
392
  size_t rsize = 0;
@@ -360,6 +402,7 @@ write_section_irep(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *len_p,
360
402
  if (result != MRB_DUMP_OK) {
361
403
  return result;
362
404
  }
405
+ mrb_assert(rsize == get_irep_record_size(mrb, irep));
363
406
  *len_p = cur - bin + rsize;
364
407
  write_section_irep_header(mrb, *len_p, bin);
365
408
 
@@ -367,7 +410,7 @@ write_section_irep(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *len_p,
367
410
  }
368
411
 
369
412
  static size_t
370
- get_debug_record_size(mrb_state *mrb, mrb_irep *irep)
413
+ get_debug_record_size(mrb_state *mrb, const mrb_irep *irep)
371
414
  {
372
415
  size_t ret = 0;
373
416
  uint16_t f_idx;
@@ -416,11 +459,11 @@ find_filename_index(const mrb_sym *ary, int ary_len, mrb_sym s)
416
459
  }
417
460
 
418
461
  static size_t
419
- get_filename_table_size(mrb_state *mrb, mrb_irep *irep, mrb_sym **fp, uint16_t *lp)
462
+ get_filename_table_size(mrb_state *mrb, const mrb_irep *irep, mrb_sym **fp, uint16_t *lp)
420
463
  {
421
464
  mrb_sym *filenames = *fp;
422
465
  size_t size = 0;
423
- mrb_irep_debug_info *di = irep->debug_info;
466
+ const mrb_irep_debug_info *di = irep->debug_info;
424
467
  int i;
425
468
 
426
469
  mrb_assert(lp);
@@ -447,7 +490,7 @@ get_filename_table_size(mrb_state *mrb, mrb_irep *irep, mrb_sym **fp, uint16_t *
447
490
  }
448
491
 
449
492
  static size_t
450
- write_debug_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const* filenames, uint16_t filenames_len)
493
+ write_debug_record_1(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, mrb_sym const* filenames, uint16_t filenames_len)
451
494
  {
452
495
  uint8_t *cur;
453
496
  uint16_t f_idx;
@@ -501,7 +544,7 @@ write_debug_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const
501
544
  }
502
545
 
503
546
  static size_t
504
- write_debug_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const* filenames, uint16_t filenames_len)
547
+ write_debug_record(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, mrb_sym const* filenames, uint16_t filenames_len)
505
548
  {
506
549
  size_t size, len;
507
550
  int irep_no;
@@ -519,7 +562,7 @@ write_debug_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const*
519
562
  }
520
563
 
521
564
  static int
522
- write_section_debug(mrb_state *mrb, mrb_irep *irep, uint8_t *cur, mrb_sym const *filenames, uint16_t filenames_len)
565
+ write_section_debug(mrb_state *mrb, const mrb_irep *irep, uint8_t *cur, mrb_sym const *filenames, uint16_t filenames_len)
523
566
  {
524
567
  size_t section_size = 0;
525
568
  const uint8_t *bin = cur;
@@ -569,7 +612,7 @@ create_lv_sym_table(mrb_state *mrb, const mrb_irep *irep, mrb_sym **syms, uint32
569
612
  }
570
613
 
571
614
  for (i = 0; i + 1 < irep->nlocals; ++i) {
572
- mrb_sym const name = irep->lv[i].name;
615
+ mrb_sym const name = irep->lv[i];
573
616
  if (name == 0) continue;
574
617
  if (find_filename_index(*syms, *syms_len, name) != -1) continue;
575
618
 
@@ -612,16 +655,14 @@ write_lv_record(mrb_state *mrb, const mrb_irep *irep, uint8_t **start, mrb_sym c
612
655
  int i;
613
656
 
614
657
  for (i = 0; i + 1 < irep->nlocals; ++i) {
615
- if (irep->lv[i].name == 0) {
658
+ if (irep->lv[i] == 0) {
616
659
  cur += uint16_to_bin(RITE_LV_NULL_MARK, cur);
617
- cur += uint16_to_bin(0, cur);
618
660
  }
619
661
  else {
620
- int const sym_idx = find_filename_index(syms, syms_len, irep->lv[i].name);
662
+ int const sym_idx = find_filename_index(syms, syms_len, irep->lv[i]);
621
663
  mrb_assert(sym_idx != -1); /* local variable name must be in syms */
622
664
 
623
665
  cur += uint16_to_bin(sym_idx, cur);
624
- cur += uint16_to_bin(irep->lv[i].r, cur);
625
666
  }
626
667
  }
627
668
 
@@ -635,12 +676,12 @@ write_lv_record(mrb_state *mrb, const mrb_irep *irep, uint8_t **start, mrb_sym c
635
676
  }
636
677
 
637
678
  static size_t
638
- get_lv_record_size(mrb_state *mrb, mrb_irep *irep)
679
+ get_lv_record_size(mrb_state *mrb, const mrb_irep *irep)
639
680
  {
640
681
  size_t ret = 0;
641
682
  int i;
642
683
 
643
- ret += (sizeof(uint16_t) + sizeof(uint16_t)) * (irep->nlocals - 1);
684
+ ret += sizeof(uint16_t) * (irep->nlocals - 1);
644
685
 
645
686
  for (i = 0; i < irep->rlen; ++i) {
646
687
  ret += get_lv_record_size(mrb, irep->reps[i]);
@@ -650,7 +691,7 @@ get_lv_record_size(mrb_state *mrb, mrb_irep *irep)
650
691
  }
651
692
 
652
693
  static size_t
653
- get_lv_section_size(mrb_state *mrb, mrb_irep *irep, mrb_sym const *syms, uint32_t syms_len)
694
+ get_lv_section_size(mrb_state *mrb, const mrb_irep *irep, mrb_sym const *syms, uint32_t syms_len)
654
695
  {
655
696
  size_t ret = 0, i;
656
697
 
@@ -668,7 +709,7 @@ get_lv_section_size(mrb_state *mrb, mrb_irep *irep, mrb_sym const *syms, uint32_
668
709
  }
669
710
 
670
711
  static int
671
- write_section_lv(mrb_state *mrb, mrb_irep *irep, uint8_t *start, mrb_sym const *syms, uint32_t const syms_len)
712
+ write_section_lv(mrb_state *mrb, const mrb_irep *irep, uint8_t *start, mrb_sym const *syms, uint32_t const syms_len)
672
713
  {
673
714
  uint8_t *cur = start;
674
715
  struct rite_section_lv_header *header;
@@ -706,40 +747,20 @@ static int
706
747
  write_rite_binary_header(mrb_state *mrb, size_t binary_size, uint8_t *bin, uint8_t flags)
707
748
  {
708
749
  struct rite_binary_header *header = (struct rite_binary_header *)bin;
709
- uint16_t crc;
710
- uint32_t offset;
711
-
712
- switch (flags & DUMP_ENDIAN_NAT) {
713
- endian_big:
714
- case DUMP_ENDIAN_BIG:
715
- memcpy(header->binary_ident, RITE_BINARY_IDENT, sizeof(header->binary_ident));
716
- break;
717
- endian_little:
718
- case DUMP_ENDIAN_LIL:
719
- memcpy(header->binary_ident, RITE_BINARY_IDENT_LIL, sizeof(header->binary_ident));
720
- break;
721
-
722
- case DUMP_ENDIAN_NAT:
723
- if (bigendian_p()) goto endian_big;
724
- goto endian_little;
725
- break;
726
- }
727
-
728
- memcpy(header->binary_version, RITE_BINARY_FORMAT_VER, sizeof(header->binary_version));
750
+
751
+ memcpy(header->binary_ident, RITE_BINARY_IDENT, sizeof(header->binary_ident));
752
+ memcpy(header->major_version, RITE_BINARY_MAJOR_VER, sizeof(header->major_version));
753
+ memcpy(header->minor_version, RITE_BINARY_MINOR_VER, sizeof(header->minor_version));
729
754
  memcpy(header->compiler_name, RITE_COMPILER_NAME, sizeof(header->compiler_name));
730
755
  memcpy(header->compiler_version, RITE_COMPILER_VERSION, sizeof(header->compiler_version));
731
756
  mrb_assert(binary_size <= UINT32_MAX);
732
757
  uint32_to_bin((uint32_t)binary_size, header->binary_size);
733
758
 
734
- offset = (uint32_t)((&(header->binary_crc[0]) - bin) + sizeof(uint16_t));
735
- crc = calc_crc_16_ccitt(bin + offset, binary_size - offset, 0);
736
- uint16_to_bin(crc, header->binary_crc);
737
-
738
759
  return MRB_DUMP_OK;
739
760
  }
740
761
 
741
762
  static mrb_bool
742
- debug_info_defined_p(mrb_irep *irep)
763
+ debug_info_defined_p(const mrb_irep *irep)
743
764
  {
744
765
  int i;
745
766
 
@@ -751,7 +772,7 @@ debug_info_defined_p(mrb_irep *irep)
751
772
  }
752
773
 
753
774
  static mrb_bool
754
- lv_defined_p(mrb_irep *irep)
775
+ lv_defined_p(const mrb_irep *irep)
755
776
  {
756
777
  int i;
757
778
 
@@ -764,23 +785,8 @@ lv_defined_p(mrb_irep *irep)
764
785
  return FALSE;
765
786
  }
766
787
 
767
- static uint8_t
768
- dump_flags(uint8_t flags, uint8_t native)
769
- {
770
- if (native == FLAG_BYTEORDER_NATIVE) {
771
- if ((flags & DUMP_ENDIAN_NAT) == 0) {
772
- return (flags & DUMP_DEBUG_INFO) | DUMP_ENDIAN_NAT;
773
- }
774
- return flags;
775
- }
776
- if ((flags & DUMP_ENDIAN_NAT) == 0) {
777
- return (flags & DUMP_DEBUG_INFO) | DUMP_ENDIAN_BIG;
778
- }
779
- return flags;
780
- }
781
-
782
788
  static int
783
- dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
789
+ dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
784
790
  {
785
791
  int result = MRB_DUMP_GENERAL_FAILURE;
786
792
  size_t malloc_size;
@@ -868,15 +874,15 @@ error_exit:
868
874
  }
869
875
 
870
876
  int
871
- mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
877
+ mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
872
878
  {
873
- return dump_irep(mrb, irep, dump_flags(flags, FLAG_BYTEORDER_NONATIVE), bin, bin_size);
879
+ return dump_irep(mrb, irep, flags, bin, bin_size);
874
880
  }
875
881
 
876
- #ifndef MRB_DISABLE_STDIO
882
+ #ifndef MRB_NO_STDIO
877
883
 
878
884
  int
879
- mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
885
+ mrb_dump_irep_binary(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE* fp)
880
886
  {
881
887
  uint8_t *bin = NULL;
882
888
  size_t bin_size = 0;
@@ -886,7 +892,7 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
886
892
  return MRB_DUMP_INVALID_ARGUMENT;
887
893
  }
888
894
 
889
- result = dump_irep(mrb, irep, dump_flags(flags, FLAG_BYTEORDER_NONATIVE), &bin, &bin_size);
895
+ result = dump_irep(mrb, irep, flags, &bin, &bin_size);
890
896
  if (result == MRB_DUMP_OK) {
891
897
  if (fwrite(bin, sizeof(bin[0]), bin_size, fp) != bin_size) {
892
898
  result = MRB_DUMP_WRITE_FAULT;
@@ -897,22 +903,8 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
897
903
  return result;
898
904
  }
899
905
 
900
- static mrb_bool
901
- dump_bigendian_p(uint8_t flags)
902
- {
903
- switch (flags & DUMP_ENDIAN_NAT) {
904
- case DUMP_ENDIAN_BIG:
905
- return TRUE;
906
- case DUMP_ENDIAN_LIL:
907
- return FALSE;
908
- default:
909
- case DUMP_ENDIAN_NAT:
910
- return bigendian_p();
911
- }
912
- }
913
-
914
906
  int
915
- mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
907
+ mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
916
908
  {
917
909
  uint8_t *bin = NULL;
918
910
  size_t bin_size = 0, bin_idx = 0;
@@ -921,23 +913,8 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
921
913
  if (fp == NULL || initname == NULL || initname[0] == '\0') {
922
914
  return MRB_DUMP_INVALID_ARGUMENT;
923
915
  }
924
- flags = dump_flags(flags, FLAG_BYTEORDER_NATIVE);
925
916
  result = dump_irep(mrb, irep, flags, &bin, &bin_size);
926
917
  if (result == MRB_DUMP_OK) {
927
- if (!dump_bigendian_p(flags)) {
928
- if (fprintf(fp, "/* dumped in little endian order.\n"
929
- " use `mrbc -E` option for big endian CPU. */\n") < 0) {
930
- mrb_free(mrb, bin);
931
- return MRB_DUMP_WRITE_FAULT;
932
- }
933
- }
934
- else {
935
- if (fprintf(fp, "/* dumped in big endian order.\n"
936
- " use `mrbc -e` option for better performance on little endian CPU. */\n") < 0) {
937
- mrb_free(mrb, bin);
938
- return MRB_DUMP_WRITE_FAULT;
939
- }
940
- }
941
918
  if (fprintf(fp, "#include <stdint.h>\n") < 0) { /* for uint8_t under at least Darwin */
942
919
  mrb_free(mrb, bin);
943
920
  return MRB_DUMP_WRITE_FAULT;
@@ -946,15 +923,8 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
946
923
  "#ifdef __cplusplus\n"
947
924
  "extern const uint8_t %s[];\n"
948
925
  "#endif\n"
949
- "const uint8_t\n"
950
- "#if defined __GNUC__\n"
951
- "__attribute__((aligned(%u)))\n"
952
- "#elif defined _MSC_VER\n"
953
- "__declspec(align(%u))\n"
954
- "#endif\n"
955
- "%s[] = {",
956
- initname,
957
- (uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) {
926
+ "const uint8_t %s[] = {",
927
+ initname, initname) < 0) {
958
928
  mrb_free(mrb, bin);
959
929
  return MRB_DUMP_WRITE_FAULT;
960
930
  }
@@ -980,4 +950,297 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
980
950
  return result;
981
951
  }
982
952
 
983
- #endif /* MRB_DISABLE_STDIO */
953
+ static int
954
+ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
955
+ {
956
+ if (p->tt & IREP_TT_NFLAG) { /* number */
957
+ switch (p->tt) {
958
+ #ifdef MRB_64BIT
959
+ case IREP_TT_INT64:
960
+ if (p->u.i64 < INT32_MIN || INT32_MAX < p->u.i64) {
961
+ fprintf(fp, "{IREP_TT_INT64, {.i64=%" PRId64 "}},\n", p->u.i64);
962
+ }
963
+ else {
964
+ fprintf(fp, "{IREP_TT_INT32, {.i32=%" PRId32 "}},\n", (int32_t)p->u.i64);
965
+ }
966
+ break;
967
+ #endif
968
+ case IREP_TT_INT32:
969
+ fprintf(fp, "{IREP_TT_INT32, {.i32=%" PRId32 "}},\n", p->u.i32);
970
+ break;
971
+ case IREP_TT_FLOAT:
972
+ #ifndef MRB_NO_FLOAT
973
+ if (p->u.f == 0) {
974
+ fprintf(fp, "{IREP_TT_FLOAT, {.f=%#.1f}},\n", p->u.f);
975
+ }
976
+ else {
977
+ fprintf(fp, "{IREP_TT_FLOAT, {.f=" MRB_FLOAT_FMT "}},\n", p->u.f);
978
+ }
979
+ #endif
980
+ break;
981
+ }
982
+ }
983
+ else { /* string */
984
+ int i, len = p->tt>>2;
985
+ const char *s = p->u.str;
986
+ fprintf(fp, "{IREP_TT_STR|(%d<<2), {\"", len);
987
+ for (i=0; i<len; i++) {
988
+ fprintf(fp, "\\x%02x", (int)s[i]&0xff);
989
+ }
990
+ fputs("\"}},\n", fp);
991
+ }
992
+ return MRB_DUMP_OK;
993
+ }
994
+
995
+ static mrb_bool
996
+ sym_name_word_p(const char *name, mrb_int len)
997
+ {
998
+ if (len == 0) return FALSE;
999
+ if (name[0] != '_' && !ISALPHA(name[0])) return FALSE;
1000
+ for (int i = 1; i < len; i++) {
1001
+ if (name[i] != '_' && !ISALNUM(name[i])) return FALSE;
1002
+ }
1003
+ return TRUE;
1004
+ }
1005
+
1006
+ static mrb_bool
1007
+ sym_name_with_equal_p(const char *name, mrb_int len)
1008
+ {
1009
+ return len >= 2 && name[len-1] == '=' && sym_name_word_p(name, len-1);
1010
+ }
1011
+
1012
+ static mrb_bool
1013
+ sym_name_with_question_mark_p(const char *name, mrb_int len)
1014
+ {
1015
+ return len >= 2 && name[len-1] == '?' && sym_name_word_p(name, len-1);
1016
+ }
1017
+
1018
+ static mrb_bool
1019
+ sym_name_with_bang_p(const char *name, mrb_int len)
1020
+ {
1021
+ return len >= 2 && name[len-1] == '!' && sym_name_word_p(name, len-1);
1022
+ }
1023
+
1024
+ static mrb_bool
1025
+ sym_name_ivar_p(const char *name, mrb_int len)
1026
+ {
1027
+ return len >= 2 && name[0] == '@' && sym_name_word_p(name+1, len-1);
1028
+ }
1029
+
1030
+ static mrb_bool
1031
+ sym_name_cvar_p(const char *name, mrb_int len)
1032
+ {
1033
+ return len >= 3 && name[0] == '@' && sym_name_ivar_p(name+1, len-1);
1034
+ }
1035
+
1036
+ static const char*
1037
+ sym_operator_name(const char *sym_name, mrb_int len)
1038
+ {
1039
+ mrb_sym table_size = sizeof(operator_table)/sizeof(struct operator_symbol);
1040
+ if (operator_table[table_size-1].sym_name_len < len) return NULL;
1041
+
1042
+ mrb_sym start, idx;
1043
+ int cmp;
1044
+ const struct operator_symbol *op_sym;
1045
+ for (start = 0; table_size != 0; table_size/=2) {
1046
+ idx = start+table_size/2;
1047
+ op_sym = &operator_table[idx];
1048
+ cmp = (int)len-(int)op_sym->sym_name_len;
1049
+ if (cmp == 0) {
1050
+ cmp = memcmp(sym_name, op_sym->sym_name, len);
1051
+ if (cmp == 0) return op_sym->name;
1052
+ }
1053
+ if (0 < cmp) {
1054
+ start = ++idx;
1055
+ --table_size;
1056
+ }
1057
+ }
1058
+ return NULL;
1059
+ }
1060
+
1061
+ static const char*
1062
+ sym_var_name(mrb_state *mrb, const char *initname, const char *key, int n)
1063
+ {
1064
+ char buf[32];
1065
+ mrb_value s = mrb_str_new_cstr(mrb, initname);
1066
+ mrb_str_cat_lit(mrb, s, "_");
1067
+ mrb_str_cat_cstr(mrb, s, key);
1068
+ mrb_str_cat_lit(mrb, s, "_");
1069
+ snprintf(buf, sizeof(buf), "%d", n);
1070
+ mrb_str_cat_cstr(mrb, s, buf);
1071
+ return RSTRING_PTR(s);
1072
+ }
1073
+
1074
+ static int
1075
+ dump_sym(mrb_state *mrb, mrb_sym sym, const char *var_name, int idx, mrb_value init_syms_code, FILE *fp)
1076
+ {
1077
+ if (sym == 0) return MRB_DUMP_INVALID_ARGUMENT;
1078
+
1079
+ mrb_int len;
1080
+ const char *name = mrb_sym_name_len(mrb, sym, &len), *op_name;
1081
+ if (!name) return MRB_DUMP_INVALID_ARGUMENT;
1082
+ if (sym_name_word_p(name, len)) {
1083
+ fprintf(fp, "MRB_SYM(%s)", name);
1084
+ }
1085
+ else if (sym_name_with_equal_p(name, len)) {
1086
+ fprintf(fp, "MRB_SYM_E(%.*s)", (int)(len-1), name);
1087
+ }
1088
+ else if (sym_name_with_question_mark_p(name, len)) {
1089
+ fprintf(fp, "MRB_SYM_Q(%.*s)", (int)(len-1), name);
1090
+ }
1091
+ else if (sym_name_with_bang_p(name, len)) {
1092
+ fprintf(fp, "MRB_SYM_B(%.*s)", (int)(len-1), name);
1093
+ }
1094
+ else if (sym_name_ivar_p(name, len)) {
1095
+ fprintf(fp, "MRB_IVSYM(%s)", name+1);
1096
+ }
1097
+ else if (sym_name_cvar_p(name, len)) {
1098
+ fprintf(fp, "MRB_CVSYM(%s)", name+2);
1099
+ }
1100
+ else if ((op_name = sym_operator_name(name, len))) {
1101
+ fprintf(fp, "MRB_OPSYM(%s)", op_name);
1102
+ }
1103
+ else {
1104
+ char buf[32];
1105
+ mrb_value name_obj = mrb_str_new(mrb, name, len);
1106
+ mrb_str_cat_lit(mrb, init_syms_code, " ");
1107
+ mrb_str_cat_cstr(mrb, init_syms_code, var_name);
1108
+ snprintf(buf, sizeof(buf), "[%d] = ", idx);
1109
+ mrb_str_cat_cstr(mrb, init_syms_code, buf);
1110
+ mrb_str_cat_lit(mrb, init_syms_code, "mrb_intern_lit(mrb, ");
1111
+ mrb_str_cat_str(mrb, init_syms_code, mrb_str_dump(mrb, name_obj));
1112
+ mrb_str_cat_lit(mrb, init_syms_code, ");\n");
1113
+ fputs("0", fp);
1114
+ }
1115
+ fputs(", ", fp);
1116
+ return MRB_DUMP_OK;
1117
+ }
1118
+
1119
+ static int
1120
+ dump_syms(mrb_state *mrb, const char *name, const char *key, int n, int syms_len, const mrb_sym *syms, mrb_value init_syms_code, FILE *fp)
1121
+ {
1122
+ int ai = mrb_gc_arena_save(mrb);
1123
+ mrb_int code_len = RSTRING_LEN(init_syms_code);
1124
+ const char *var_name = sym_var_name(mrb, name, key, n);
1125
+ fprintf(fp, "mrb_DEFINE_SYMS_VAR(%s, %d, (", var_name, syms_len);
1126
+ for (int i=0; i<syms_len; i++) {
1127
+ dump_sym(mrb, syms[i], var_name, i, init_syms_code, fp);
1128
+ }
1129
+ fputs("), ", fp);
1130
+ if (code_len == RSTRING_LEN(init_syms_code)) fputs("const", fp);
1131
+ fputs(");\n", fp);
1132
+ mrb_gc_arena_restore(mrb, ai);
1133
+ return MRB_DUMP_OK;
1134
+ }
1135
+
1136
+ static int
1137
+ dump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *name, int n, mrb_value init_syms_code, int *mp)
1138
+ {
1139
+ int i, len;
1140
+ int max = *mp;
1141
+
1142
+ /* dump reps */
1143
+ if (irep->reps) {
1144
+ for (i=0,len=irep->rlen; i<len; i++) {
1145
+ *mp += len;
1146
+ if (dump_irep_struct(mrb, irep->reps[i], flags, fp, name, max+i, init_syms_code, mp) != MRB_DUMP_OK)
1147
+ return MRB_DUMP_INVALID_ARGUMENT;
1148
+ }
1149
+ fprintf(fp, "static const mrb_irep *%s_reps_%d[%d] = {\n", name, n, len);
1150
+ for (i=0,len=irep->rlen; i<len; i++) {
1151
+ fprintf(fp, " &%s_irep_%d,\n", name, max+i);
1152
+ }
1153
+ fputs("};\n", fp);
1154
+ }
1155
+ /* dump pool */
1156
+ if (irep->pool) {
1157
+ len=irep->plen;
1158
+ fprintf(fp, "static const mrb_pool_value %s_pool_%d[%d] = {\n", name, n, len);
1159
+ for (i=0; i<len; i++) {
1160
+ if (dump_pool(mrb, &irep->pool[i], fp) != MRB_DUMP_OK)
1161
+ return MRB_DUMP_INVALID_ARGUMENT;
1162
+ }
1163
+ fputs("};\n", fp);
1164
+ }
1165
+ /* dump syms */
1166
+ if (irep->syms) {
1167
+ dump_syms(mrb, name, "syms", n, irep->slen, irep->syms, init_syms_code, fp);
1168
+ }
1169
+ /* dump iseq */
1170
+ len=irep->ilen+sizeof(struct mrb_irep_catch_handler)*irep->clen;
1171
+ fprintf(fp, "static const mrb_code %s_iseq_%d[%d] = {", name, n, len);
1172
+ for (i=0; i<len; i++) {
1173
+ if (i%20 == 0) fputs("\n", fp);
1174
+ fprintf(fp, "0x%02x,", irep->iseq[i]);
1175
+ }
1176
+ fputs("};\n", fp);
1177
+ /* dump lv */
1178
+ if (irep->lv) {
1179
+ dump_syms(mrb, name, "lv", n, irep->nlocals-1, irep->lv, init_syms_code, fp);
1180
+ }
1181
+ /* dump irep */
1182
+ fprintf(fp, "static const mrb_irep %s_irep_%d = {\n", name, n);
1183
+ fprintf(fp, " %d,%d,%d,\n", irep->nlocals, irep->nregs, irep->clen);
1184
+ fprintf(fp, " MRB_IREP_STATIC,%s_iseq_%d,\n", name, n);
1185
+ if (irep->pool) {
1186
+ fprintf(fp, " %s_pool_%d,", name, n);
1187
+ }
1188
+ else {
1189
+ fputs( " NULL,", fp);
1190
+ }
1191
+ if (irep->syms) {
1192
+ fprintf(fp, "%s_syms_%d,", name, n);
1193
+ }
1194
+ else {
1195
+ fputs( "NULL,", fp);
1196
+ }
1197
+ if (irep->reps) {
1198
+ fprintf(fp, "%s_reps_%d,\n", name, n);
1199
+ }
1200
+ else {
1201
+ fputs( "NULL,\n", fp);
1202
+ }
1203
+ if (irep->lv) {
1204
+ fprintf(fp, " %s_lv_%d,\n", name, n);
1205
+ }
1206
+ else {
1207
+ fputs( " NULL,\t\t\t\t\t/* lv */\n", fp);
1208
+ }
1209
+ fputs( " NULL,\t\t\t\t\t/* debug_info */\n", fp);
1210
+ fprintf(fp, " %d,%d,%d,%d,0\n};\n", irep->ilen, irep->plen, irep->slen, irep->rlen);
1211
+
1212
+ return MRB_DUMP_OK;
1213
+ }
1214
+
1215
+ int
1216
+ mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
1217
+ {
1218
+ if (fp == NULL || initname == NULL || initname[0] == '\0') {
1219
+ return MRB_DUMP_INVALID_ARGUMENT;
1220
+ }
1221
+ if (fprintf(fp, "#include <mruby.h>\n"
1222
+ "#include <mruby/proc.h>\n"
1223
+ "#include <mruby/presym.h>\n"
1224
+ "\n") < 0) {
1225
+ return MRB_DUMP_WRITE_FAULT;
1226
+ }
1227
+ fputs("#define mrb_BRACED(...) {__VA_ARGS__}\n", fp);
1228
+ fputs("#define mrb_DEFINE_SYMS_VAR(name, len, syms, qualifier) \\\n", fp);
1229
+ fputs(" static qualifier mrb_sym name[len] = mrb_BRACED syms\n", fp);
1230
+ fputs("\n", fp);
1231
+ mrb_value init_syms_code = mrb_str_new_capa(mrb, 0);
1232
+ int max = 1;
1233
+ int n = dump_irep_struct(mrb, irep, flags, fp, initname, 0, init_syms_code, &max);
1234
+ if (n != MRB_DUMP_OK) return n;
1235
+ fprintf(fp, "#ifdef __cplusplus\nextern const struct RProc %s[];\n#endif\n", initname);
1236
+ fprintf(fp, "const struct RProc %s[] = {{\n", initname);
1237
+ fprintf(fp, "NULL,NULL,MRB_TT_PROC,7,0,{&%s_irep_0},NULL,{NULL},\n}};\n", initname);
1238
+ fputs("static void\n", fp);
1239
+ fprintf(fp, "%s_init_syms(mrb_state *mrb)\n", initname);
1240
+ fputs("{\n", fp);
1241
+ fputs(RSTRING_PTR(init_syms_code), fp);
1242
+ fputs("}\n", fp);
1243
+ return MRB_DUMP_OK;
1244
+ }
1245
+
1246
+ #endif /* MRB_NO_STDIO */