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.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -57
- data/.ruby-version +1 -1
- data/Gemfile +2 -2
- data/README.md +7 -1
- data/ext/enterprise_script_service/Rakefile +1 -1
- data/ext/enterprise_script_service/libseccomp/.travis.yml +24 -12
- data/ext/enterprise_script_service/libseccomp/CHANGELOG +32 -0
- data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
- data/ext/enterprise_script_service/libseccomp/CREDITS +11 -0
- data/ext/enterprise_script_service/libseccomp/README.md +21 -1
- data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
- data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
- data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +19 -0
- data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
- data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
- data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
- data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
- data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
- data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
- data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
- data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
- data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
- data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
- data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
- data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
- data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
- data/ext/enterprise_script_service/libseccomp/tests/.gitignore +10 -2
- data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
- data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
- data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +4 -3
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
- data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.c +48 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.py +38 -0
- data/ext/enterprise_script_service/libseccomp/tests/52-basic-load.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +34 -10
- data/ext/enterprise_script_service/libseccomp/tests/regression +10 -3
- data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -3
- data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
- data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +4 -0
- data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
- data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +149 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +55 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/lint.yml +23 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/oss-fuzz.yml +27 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/spell-checker.yml +17 -0
- data/ext/enterprise_script_service/mruby/.gitignore +3 -0
- data/ext/enterprise_script_service/mruby/.gitlab-ci.yml +3 -3
- data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
- data/ext/enterprise_script_service/mruby/.travis.yml +7 -10
- data/ext/enterprise_script_service/mruby/.yamllint +8 -0
- data/ext/enterprise_script_service/mruby/AUTHORS +4 -0
- data/ext/enterprise_script_service/mruby/CODEOWNERS +1 -0
- data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +6 -13
- data/ext/enterprise_script_service/mruby/Doxyfile +4 -4
- data/ext/enterprise_script_service/mruby/LICENSE +1 -1
- data/ext/enterprise_script_service/mruby/Makefile +1 -1
- data/ext/enterprise_script_service/mruby/README.md +5 -11
- data/ext/enterprise_script_service/mruby/Rakefile +18 -108
- data/ext/enterprise_script_service/mruby/TODO.md +17 -0
- data/ext/enterprise_script_service/mruby/appveyor.yml +29 -26
- data/ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb +1 -1
- data/ext/enterprise_script_service/mruby/build_config.rb +9 -152
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_ArduinoDue.rb → build_config/ArduinoDue.rb} +4 -21
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +4 -4
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +3 -20
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +4 -21
- data/ext/enterprise_script_service/mruby/build_config/android_arm64-v8a.rb +11 -0
- data/ext/enterprise_script_service/mruby/build_config/android_armeabi.rb +11 -0
- 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
- data/ext/enterprise_script_service/mruby/build_config/bench.rb +11 -0
- data/ext/enterprise_script_service/mruby/build_config/boxing.rb +21 -0
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_chipKITMax32.rb → build_config/chipKITMax32.rb} +4 -21
- data/ext/enterprise_script_service/mruby/{appveyor_config.rb → build_config/ci/gcc-clang.rb} +11 -8
- data/ext/enterprise_script_service/mruby/build_config/ci/msvc.rb +20 -0
- data/ext/enterprise_script_service/mruby/build_config/clang-asan.rb +11 -0
- data/ext/enterprise_script_service/mruby/build_config/cross-32bit.rb +14 -0
- data/ext/enterprise_script_service/mruby/build_config/default.rb +80 -0
- data/ext/enterprise_script_service/mruby/build_config/dreamcast_shelf.rb +94 -0
- data/ext/enterprise_script_service/mruby/build_config/gameboyadvance.rb +73 -0
- data/ext/enterprise_script_service/mruby/build_config/host-cxx.rb +12 -0
- data/ext/enterprise_script_service/mruby/build_config/host-debug.rb +20 -0
- data/ext/enterprise_script_service/mruby/build_config/host-gprof.rb +14 -0
- data/ext/enterprise_script_service/mruby/build_config/host-m32.rb +15 -0
- data/ext/enterprise_script_service/mruby/build_config/host-shared.rb +36 -0
- data/ext/enterprise_script_service/mruby/build_config/mrbc.rb +11 -0
- data/ext/enterprise_script_service/mruby/build_config/no-float.rb +17 -0
- data/ext/enterprise_script_service/mruby/doc/guides/compile.md +142 -49
- data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +5 -4
- data/ext/enterprise_script_service/mruby/doc/guides/gc-arena-howto.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +53 -30
- data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +31 -14
- data/ext/enterprise_script_service/mruby/doc/guides/symbol.md +83 -0
- data/ext/enterprise_script_service/mruby/doc/limitations.md +35 -36
- data/ext/enterprise_script_service/mruby/doc/mruby3.md +163 -0
- data/ext/enterprise_script_service/mruby/doc/opcode.md +102 -103
- data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +1 -1
- data/ext/enterprise_script_service/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +5 -1
- data/ext/enterprise_script_service/mruby/examples/mrbgems/c_extension_example/src/example.c +5 -1
- data/ext/enterprise_script_service/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +1 -1
- data/ext/enterprise_script_service/mruby/include/mrbconf.h +88 -66
- data/ext/enterprise_script_service/mruby/include/mruby.h +160 -104
- data/ext/enterprise_script_service/mruby/include/mruby/array.h +27 -6
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +80 -46
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +76 -55
- data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
- data/ext/enterprise_script_service/mruby/include/mruby/common.h +14 -1
- data/ext/enterprise_script_service/mruby/include/mruby/compile.h +20 -6
- data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/dump.h +18 -52
- data/ext/enterprise_script_service/mruby/include/mruby/endian.h +44 -0
- data/ext/enterprise_script_service/mruby/include/mruby/error.h +39 -5
- data/ext/enterprise_script_service/mruby/include/mruby/gc.h +1 -0
- data/ext/enterprise_script_service/mruby/include/mruby/hash.h +33 -13
- data/ext/enterprise_script_service/mruby/include/mruby/irep.h +74 -14
- data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -1
- data/ext/enterprise_script_service/mruby/include/mruby/khash.h +19 -9
- data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +37 -63
- data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
- data/ext/enterprise_script_service/mruby/include/mruby/ops.h +29 -24
- data/ext/enterprise_script_service/mruby/include/mruby/presym.h +40 -0
- data/ext/enterprise_script_service/mruby/include/mruby/presym/disable.h +70 -0
- data/ext/enterprise_script_service/mruby/include/mruby/presym/enable.h +37 -0
- data/ext/enterprise_script_service/mruby/include/mruby/presym/scanning.h +73 -0
- data/ext/enterprise_script_service/mruby/include/mruby/proc.h +93 -21
- data/ext/enterprise_script_service/mruby/include/mruby/string.h +12 -16
- data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +60 -59
- data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +25 -6
- data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -72
- data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +71 -78
- data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +12 -10
- data/ext/enterprise_script_service/mruby/lib/{mruby-core-ext.rb → mruby/core_ext.rb} +10 -3
- data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +84 -32
- data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +1 -1
- data/ext/enterprise_script_service/mruby/lib/mruby/presym.rb +132 -0
- data/ext/enterprise_script_service/mruby/lib/mruby/source.rb +3 -1
- data/ext/enterprise_script_service/mruby/mrbgems/default-no-fpu.gembox +3 -0
- data/ext/enterprise_script_service/mruby/mrbgems/default-no-stdio.gembox +4 -0
- data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +9 -81
- data/ext/enterprise_script_service/mruby/mrbgems/full-core.gembox +1 -4
- data/ext/enterprise_script_service/mruby/mrbgems/math.gembox +10 -0
- data/ext/enterprise_script_service/mruby/mrbgems/metaprog.gembox +15 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +1 -32
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +10 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +0 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +30 -18
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mruby-config +18 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +3 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +10 -10
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +14 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +4 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +2 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +23 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +11 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +46 -35
- data/ext/enterprise_script_service/mruby/mrbgems/{mruby-compiler → mruby-bin-mrbc}/bintest/mrbc.rb +0 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/mrbgem.rake +3 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +41 -28
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +25 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +26 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +6 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrbgem.rake +5 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-catch/mrblib/catch.rb +27 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +495 -436
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +5 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +49 -44
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +637 -220
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +13734 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +20 -23
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +9 -9
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +4 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +1 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/mrbgem.rake +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +19 -238
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +21 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +19 -15
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +31 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +7 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +5 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +18 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/include/mruby/ext/io.h +39 -7
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +2 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file_constants.rb +0 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +9 -14
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +107 -59
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +22 -38
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +417 -203
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +20 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +33 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +58 -50
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +13 -14
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +13 -12
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/test/math.rb +5 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +56 -73
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +13 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/README.md +4 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +80 -78
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +4 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +14 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +8 -16
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/mrbgem.rake +10 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/src/memsize.c +231 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-os-memsize/test/memsize.rb +63 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/README.md +15 -18
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +120 -67
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +1 -30
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +65 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +34 -21
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +98 -43
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +39 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +21 -43
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +27 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +12 -20
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +216 -38
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +6 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/README.md +6 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/src/mrb_sleep.c +5 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrbgem.rake +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/sockettest.c +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +161 -93
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +9 -25
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +23 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +17 -14
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +23 -36
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +7 -6
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/README.md +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +5 -5
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +17 -44
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +4 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +37 -41
- data/ext/enterprise_script_service/mruby/mrbgems/stdlib-ext.gembox +18 -0
- data/ext/enterprise_script_service/mruby/mrbgems/stdlib-io.gembox +12 -0
- data/ext/enterprise_script_service/mruby/mrbgems/stdlib.gembox +54 -0
- data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
- data/ext/enterprise_script_service/mruby/mrblib/10error.rb +4 -0
- data/ext/enterprise_script_service/mruby/mrblib/array.rb +17 -9
- data/ext/enterprise_script_service/mruby/mrblib/enum.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrblib/hash.rb +3 -23
- data/ext/enterprise_script_service/mruby/mrblib/init_mrblib.c +0 -11
- data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +36 -11
- data/ext/enterprise_script_service/mruby/mrblib/range.rb +25 -3
- data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +2 -2
- data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +1 -1
- data/ext/enterprise_script_service/mruby/src/array.c +67 -90
- data/ext/enterprise_script_service/mruby/src/backtrace.c +18 -19
- data/ext/enterprise_script_service/mruby/src/class.c +819 -211
- data/ext/enterprise_script_service/mruby/src/codedump.c +226 -197
- data/ext/enterprise_script_service/mruby/src/debug.c +14 -11
- data/ext/enterprise_script_service/mruby/src/dump.c +470 -207
- data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
- data/ext/enterprise_script_service/mruby/src/error.c +94 -20
- data/ext/enterprise_script_service/mruby/src/etc.c +56 -39
- data/ext/enterprise_script_service/mruby/src/fmt_fp.c +103 -27
- data/ext/enterprise_script_service/mruby/src/gc.c +86 -349
- data/ext/enterprise_script_service/mruby/src/hash.c +1058 -723
- data/ext/enterprise_script_service/mruby/src/kernel.c +78 -226
- data/ext/enterprise_script_service/mruby/src/load.c +215 -159
- data/ext/enterprise_script_service/mruby/src/numeric.c +400 -382
- data/ext/enterprise_script_service/mruby/src/object.c +115 -90
- data/ext/enterprise_script_service/mruby/src/print.c +31 -6
- data/ext/enterprise_script_service/mruby/src/proc.c +56 -45
- data/ext/enterprise_script_service/mruby/src/range.c +49 -33
- data/ext/enterprise_script_service/mruby/src/state.c +58 -42
- data/ext/enterprise_script_service/mruby/src/string.c +151 -156
- data/ext/enterprise_script_service/mruby/src/symbol.c +132 -66
- data/ext/enterprise_script_service/mruby/src/value_array.h +1 -0
- data/ext/enterprise_script_service/mruby/src/variable.c +158 -158
- data/ext/enterprise_script_service/mruby/src/vm.c +655 -645
- data/ext/enterprise_script_service/mruby/tasks/benchmark.rake +6 -6
- data/ext/enterprise_script_service/mruby/tasks/bin.rake +23 -0
- data/ext/enterprise_script_service/mruby/tasks/core.rake +12 -0
- data/ext/enterprise_script_service/mruby/tasks/doc.rake +50 -38
- data/ext/enterprise_script_service/mruby/tasks/gitlab.rake +64 -61
- data/ext/enterprise_script_service/mruby/tasks/libmruby.rake +10 -1
- data/ext/enterprise_script_service/mruby/tasks/mrbgems.rake +13 -1
- data/ext/enterprise_script_service/mruby/tasks/mrblib.rake +40 -0
- data/ext/enterprise_script_service/mruby/tasks/presym.rake +44 -0
- data/ext/enterprise_script_service/mruby/tasks/test.rake +68 -0
- data/ext/enterprise_script_service/mruby/tasks/toolchains/android.rake +46 -1
- data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +8 -7
- data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +13 -17
- data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +21 -25
- data/ext/enterprise_script_service/mruby/test/assert.rb +5 -4
- data/ext/enterprise_script_service/mruby/test/bintest.rb +5 -5
- data/ext/enterprise_script_service/mruby/test/t/argumenterror.rb +16 -0
- data/ext/enterprise_script_service/mruby/test/t/array.rb +7 -3
- data/ext/enterprise_script_service/mruby/test/t/bs_literal.rb +1 -1
- data/ext/enterprise_script_service/mruby/test/t/ensure.rb +8 -26
- data/ext/enterprise_script_service/mruby/test/t/exception.rb +2 -2
- data/ext/enterprise_script_service/mruby/test/t/float.rb +18 -8
- data/ext/enterprise_script_service/mruby/test/t/hash.rb +903 -281
- data/ext/enterprise_script_service/mruby/test/t/integer.rb +10 -38
- data/ext/enterprise_script_service/mruby/test/t/kernel.rb +16 -25
- data/ext/enterprise_script_service/mruby/test/t/literals.rb +50 -0
- data/ext/enterprise_script_service/mruby/test/t/module.rb +2 -2
- data/ext/enterprise_script_service/mruby/test/t/numeric.rb +1 -1
- data/ext/enterprise_script_service/mruby/test/t/range.rb +83 -1
- data/ext/enterprise_script_service/mruby/test/t/string.rb +4 -0
- data/ext/enterprise_script_service/mruby/test/t/superclass.rb +10 -10
- data/ext/enterprise_script_service/mruby/test/t/syntax.rb +24 -0
- data/ext/enterprise_script_service/mruby/test/t/vformat.rb +3 -3
- data/ext/enterprise_script_service/mruby_config.rb +2 -5
- data/ext/enterprise_script_service/mruby_engine.cpp +1 -1
- data/ext/enterprise_script_service/msgpack/.github/depends/boost.sh +56 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/coverage.yml +62 -0
- data/ext/enterprise_script_service/msgpack/.github/workflows/gha.yml +304 -0
- data/ext/enterprise_script_service/msgpack/CHANGELOG.md +11 -0
- data/ext/enterprise_script_service/msgpack/CMakeLists.txt +82 -39
- data/ext/enterprise_script_service/msgpack/Files.cmake +22 -12
- data/ext/enterprise_script_service/msgpack/QUICKSTART-C.md +26 -29
- data/ext/enterprise_script_service/msgpack/README.md +3 -2
- data/ext/enterprise_script_service/msgpack/appveyor.yml +6 -2
- data/ext/enterprise_script_service/msgpack/ci/build_cmake.sh +3 -1
- data/ext/enterprise_script_service/msgpack/cmake/CodeCoverage.cmake +55 -0
- data/ext/enterprise_script_service/msgpack/codecov.yml +36 -0
- data/ext/enterprise_script_service/msgpack/example/CMakeLists.txt +9 -5
- data/ext/enterprise_script_service/msgpack/example/boost/CMakeLists.txt +1 -1
- data/ext/enterprise_script_service/msgpack/example/c/CMakeLists.txt +17 -6
- data/ext/enterprise_script_service/msgpack/example/c/boundary.c +296 -0
- data/ext/enterprise_script_service/msgpack/example/c/jsonconv.c +419 -0
- data/ext/enterprise_script_service/msgpack/example/c/simple_c.c +1 -1
- data/ext/enterprise_script_service/msgpack/example/cpp03/CMakeLists.txt +3 -3
- data/ext/enterprise_script_service/msgpack/example/cpp11/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/example/x3/CMakeLists.txt +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/pack.h +24 -1
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +5 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/boost/optional.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/map.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/vector_unsigned_char.hpp +8 -8
- data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +4 -4
- data/ext/enterprise_script_service/msgpack/include/msgpack/v3/unpack.hpp +6 -6
- data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
- data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +4 -4
- data/ext/enterprise_script_service/msgpack/make_file_list.sh +38 -11
- data/ext/enterprise_script_service/msgpack/src/vrefbuffer.c +6 -0
- data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +86 -64
- data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/buffer.cpp +4 -47
- data/ext/enterprise_script_service/msgpack/test/buffer_c.cpp +148 -0
- data/ext/enterprise_script_service/msgpack/test/carray.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/cases.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/convert.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/fixint.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/json.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/limit.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +159 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +32 -27
- data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/object.cpp +4 -1
- data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +12 -8
- data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +30 -26
- data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/raw.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/streaming.cpp +8 -4
- data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/user_class.cpp +16 -12
- data/ext/enterprise_script_service/msgpack/test/version.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/visitor.cpp +4 -0
- data/ext/enterprise_script_service/msgpack/test/zone.cpp +4 -0
- data/lib/script_core/engine.rb +24 -5
- data/lib/script_core/executable.rb +4 -3
- data/lib/script_core/version.rb +1 -1
- data/lib/tasks/script_core.rake +3 -1
- data/script_core.gemspec +1 -2
- data/spec/dummy/app/lib/script_engine.rb +64 -5
- data/spec/script_core_spec.rb +13 -0
- metadata +123 -61
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
- data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -626
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -626
- data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
- data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
- data/ext/enterprise_script_service/mruby/TODO +0 -8
- data/ext/enterprise_script_service/mruby/benchmark/build_config_boxing.rb +0 -28
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_arm64-v8a.rb +0 -26
- data/ext/enterprise_script_service/mruby/examples/targets/build_config_android_armeabi.rb +0 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +0 -30
- data/ext/enterprise_script_service/mruby/mrblib/mrblib.rake +0 -18
- data/ext/enterprise_script_service/mruby/src/crc.c +0 -39
- data/ext/enterprise_script_service/mruby/src/mruby_core.rake +0 -19
- data/ext/enterprise_script_service/mruby/travis_config.rb +0 -54
- 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,
|
54
|
+
mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
|
55
55
|
{
|
56
|
-
if (irep && pc
|
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,
|
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,
|
67
|
+
mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
|
68
68
|
{
|
69
|
-
if (irep && pc
|
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,
|
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
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
#
|
17
|
-
#
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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(
|
75
|
-
size += sizeof(
|
76
|
-
size += sizeof(
|
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 +=
|
87
|
-
cur +=
|
88
|
-
memcpy(cur, irep->iseq,
|
89
|
-
cur +=
|
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
|
95
|
-
static
|
96
|
-
|
117
|
+
#ifndef MRB_NO_FLOAT
|
118
|
+
static void
|
119
|
+
dump_float(mrb_state *mrb, uint8_t *buf, mrb_float f)
|
97
120
|
{
|
98
|
-
|
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
|
-
|
101
|
-
|
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(
|
115
|
-
size += irep->plen *
|
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 (
|
121
|
-
case
|
122
|
-
|
152
|
+
switch (irep->pool[pool_no].tt) {
|
153
|
+
case IREP_TT_INT64:
|
154
|
+
#ifdef MRB_64BIT
|
123
155
|
{
|
124
|
-
|
125
|
-
|
126
|
-
|
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
|
-
|
131
|
-
|
132
|
-
str = float_to_str(mrb, irep->pool[pool_no]);
|
171
|
+
case IREP_TT_FLOAT:
|
172
|
+
#ifndef MRB_NO_FLOAT
|
133
173
|
{
|
134
|
-
|
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
|
-
|
179
|
+
default: /* packed IREP_TT_STRING */
|
142
180
|
{
|
143
|
-
mrb_int len =
|
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 += (
|
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
|
-
|
164
|
-
|
165
|
-
const char *char_ptr;
|
199
|
+
mrb_int len;
|
200
|
+
const char *ptr;
|
166
201
|
|
167
|
-
cur +=
|
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 (
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
-
|
179
|
-
case MRB_TT_FLOAT:
|
229
|
+
case IREP_TT_FLOAT:
|
180
230
|
cur += uint8_to_bin(IREP_TT_FLOAT, cur); /* data type */
|
181
|
-
|
182
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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(
|
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 +=
|
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]
|
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]
|
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]
|
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 +=
|
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
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
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,
|
879
|
+
return dump_irep(mrb, irep, flags, bin, bin_size);
|
874
880
|
}
|
875
881
|
|
876
|
-
#ifndef
|
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,
|
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
|
950
|
-
|
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
|
-
|
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 */
|