script_core 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +2 -2
- data/ext/enterprise_script_service/Rakefile +1 -1
- data/ext/enterprise_script_service/mruby/.github/workflows/build.yml +117 -74
- data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +41 -37
- 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/.gitlab-ci.yml +3 -3
- data/ext/enterprise_script_service/mruby/.markdownlint.yml +16 -0
- data/ext/enterprise_script_service/mruby/.travis.yml +2 -2
- data/ext/enterprise_script_service/mruby/.yamllint +8 -0
- data/ext/enterprise_script_service/mruby/AUTHORS +3 -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 +4 -14
- 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 +31 -25
- 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} +2 -19
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelEdison.rb → build_config/IntelEdison.rb} +2 -2
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_IntelGalileo.rb → build_config/IntelGalileo.rb} +1 -18
- data/ext/enterprise_script_service/mruby/{examples/targets/build_config_RX630.rb → build_config/RX630.rb} +2 -19
- 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} +2 -19
- data/ext/enterprise_script_service/mruby/{travis_config.rb → build_config/ci/gcc-clang.rb} +10 -10
- 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/{examples/targets/build_config_dreamcast_shelf.rb → build_config/dreamcast_shelf.rb} +5 -19
- 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 +138 -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 +49 -22
- 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 +93 -107
- 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 +81 -62
- data/ext/enterprise_script_service/mruby/include/mruby.h +137 -96
- data/ext/enterprise_script_service/mruby/include/mruby/array.h +23 -6
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +73 -48
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +8 -8
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +79 -48
- data/ext/enterprise_script_service/mruby/include/mruby/class.h +10 -8
- data/ext/enterprise_script_service/mruby/include/mruby/common.h +4 -1
- data/ext/enterprise_script_service/mruby/include/mruby/compile.h +13 -7
- data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
- data/ext/enterprise_script_service/mruby/include/mruby/dump.h +17 -35
- 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 +64 -14
- data/ext/enterprise_script_service/mruby/include/mruby/khash.h +6 -14
- data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +36 -63
- data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +1 -27
- data/ext/enterprise_script_service/mruby/include/mruby/ops.h +27 -23
- 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 +80 -13
- data/ext/enterprise_script_service/mruby/include/mruby/string.h +10 -15
- data/ext/enterprise_script_service/mruby/include/mruby/throw.h +14 -3
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +29 -19
- data/ext/enterprise_script_service/mruby/include/mruby/variable.h +1 -0
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +26 -7
- data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +198 -44
- data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +55 -37
- 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 +75 -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/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 -88
- 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 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-config/mrbgem.rake +28 -19
- 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 -3
- 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 +4 -4
- 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 +41 -34
- 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 +19 -9
- 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 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +22 -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 +2 -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 +2 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +430 -399
- 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 +559 -217
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/y.tab.c +4774 -4193
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/mrbgem.rake +18 -19
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +8 -7
- 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-eval/src/eval.c +17 -25
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +18 -13
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +30 -2
- 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 +2 -2
- 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 +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +9 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +55 -52
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +4 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +99 -87
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +2 -0
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +2 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +7 -6
- 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 +43 -58
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +4 -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 +77 -74
- 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 +5 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +18 -12
- 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 +38 -88
- 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 +62 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +32 -19
- 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 +20 -40
- 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 +11 -17
- 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 +4 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +3 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +47 -45
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +102 -71
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +4 -2
- 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 +13 -9
- 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 +18 -25
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +6 -5
- 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 +16 -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 +27 -27
- 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/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 +0 -20
- 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 +43 -80
- data/ext/enterprise_script_service/mruby/src/backtrace.c +16 -17
- data/ext/enterprise_script_service/mruby/src/class.c +774 -182
- data/ext/enterprise_script_service/mruby/src/codedump.c +223 -198
- data/ext/enterprise_script_service/mruby/src/debug.c +6 -6
- data/ext/enterprise_script_service/mruby/src/dump.c +466 -141
- data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
- data/ext/enterprise_script_service/mruby/src/error.c +36 -13
- data/ext/enterprise_script_service/mruby/src/etc.c +43 -34
- data/ext/enterprise_script_service/mruby/src/fmt_fp.c +5 -6
- data/ext/enterprise_script_service/mruby/src/gc.c +73 -71
- data/ext/enterprise_script_service/mruby/src/hash.c +1050 -707
- data/ext/enterprise_script_service/mruby/src/kernel.c +75 -220
- data/ext/enterprise_script_service/mruby/src/load.c +196 -166
- data/ext/enterprise_script_service/mruby/src/numeric.c +352 -314
- data/ext/enterprise_script_service/mruby/src/object.c +97 -90
- data/ext/enterprise_script_service/mruby/src/print.c +4 -3
- data/ext/enterprise_script_service/mruby/src/proc.c +48 -56
- data/ext/enterprise_script_service/mruby/src/range.c +45 -21
- data/ext/enterprise_script_service/mruby/src/state.c +25 -32
- data/ext/enterprise_script_service/mruby/src/string.c +59 -101
- data/ext/enterprise_script_service/mruby/src/symbol.c +121 -56
- 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 +617 -602
- 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 +83 -77
- 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/gcc.rake +6 -5
- data/ext/enterprise_script_service/mruby/tasks/toolchains/openwrt.rake +10 -14
- data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +17 -21
- 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/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 +1 -1
- 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/lib/script_core/version.rb +1 -1
- data/spec/script_core_spec.rb +13 -0
- metadata +61 -23
- data/ext/enterprise_script_service/mruby/.github/workflows/main.yml +0 -24
- data/ext/enterprise_script_service/mruby/TODO +0 -8
- data/ext/enterprise_script_service/mruby/appveyor_config.rb +0 -46
- 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
@@ -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));
|
@@ -10,33 +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
|
-
#ifndef
|
17
|
-
#
|
18
|
-
#define MRB_FLOAT_FMT "%.9g"
|
19
|
-
#else
|
15
|
+
#ifndef MRB_NO_FLOAT
|
16
|
+
#include <mruby/endian.h>
|
20
17
|
#define MRB_FLOAT_FMT "%.17g"
|
21
18
|
#endif
|
22
|
-
#endif
|
23
19
|
|
24
|
-
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);
|
25
21
|
|
26
22
|
#if UINT32_MAX > SIZE_MAX
|
27
23
|
# error This code cannot be built on your environment.
|
28
24
|
#endif
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
+
};
|
40
64
|
|
41
65
|
static size_t
|
42
66
|
get_irep_header_size(mrb_state *mrb)
|
@@ -50,7 +74,7 @@ get_irep_header_size(mrb_state *mrb)
|
|
50
74
|
}
|
51
75
|
|
52
76
|
static ptrdiff_t
|
53
|
-
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)
|
54
78
|
{
|
55
79
|
uint8_t *cur = buf;
|
56
80
|
|
@@ -62,89 +86,104 @@ write_irep_header(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
|
|
62
86
|
return cur - buf;
|
63
87
|
}
|
64
88
|
|
65
|
-
|
66
89
|
static size_t
|
67
|
-
get_iseq_block_size(mrb_state *mrb, mrb_irep *irep)
|
90
|
+
get_iseq_block_size(mrb_state *mrb, const mrb_irep *irep)
|
68
91
|
{
|
69
92
|
size_t size = 0;
|
70
93
|
|
71
|
-
size += sizeof(
|
72
|
-
size += sizeof(
|
73
|
-
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);
|
74
98
|
|
75
99
|
return size;
|
76
100
|
}
|
77
101
|
|
78
102
|
static ptrdiff_t
|
79
|
-
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)
|
80
104
|
{
|
81
105
|
uint8_t *cur = buf;
|
106
|
+
size_t seqlen = irep->ilen * sizeof(mrb_code) +
|
107
|
+
irep->clen * sizeof(struct mrb_irep_catch_handler);
|
82
108
|
|
83
|
-
cur +=
|
84
|
-
cur +=
|
85
|
-
memcpy(cur, irep->iseq,
|
86
|
-
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;
|
87
113
|
|
88
114
|
return cur - buf;
|
89
115
|
}
|
90
116
|
|
91
|
-
#ifndef
|
92
|
-
static
|
93
|
-
|
117
|
+
#ifndef MRB_NO_FLOAT
|
118
|
+
static void
|
119
|
+
dump_float(mrb_state *mrb, uint8_t *buf, mrb_float f)
|
94
120
|
{
|
95
|
-
|
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;
|
96
132
|
|
97
|
-
|
98
|
-
|
133
|
+
for (i=0; i<sizeof(double); i++) {
|
134
|
+
buf[i] = u.s[sizeof(double)-i-1];
|
135
|
+
}
|
99
136
|
}
|
100
|
-
return mrb_float_to_str(mrb, flt, MRB_FLOAT_FMT);
|
101
137
|
}
|
102
138
|
#endif
|
103
139
|
|
104
140
|
static size_t
|
105
|
-
get_pool_block_size(mrb_state *mrb, mrb_irep *irep)
|
141
|
+
get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
|
106
142
|
{
|
107
143
|
int pool_no;
|
108
144
|
size_t size = 0;
|
109
|
-
mrb_value str;
|
110
145
|
|
111
|
-
size += sizeof(
|
112
|
-
size += irep->plen *
|
146
|
+
size += sizeof(uint16_t); /* plen */
|
147
|
+
size += irep->plen * sizeof(uint8_t); /* len(n) */
|
113
148
|
|
114
149
|
for (pool_no = 0; pool_no < irep->plen; pool_no++) {
|
115
150
|
int ai = mrb_gc_arena_save(mrb);
|
116
151
|
|
117
|
-
switch (
|
118
|
-
case
|
119
|
-
|
152
|
+
switch (irep->pool[pool_no].tt) {
|
153
|
+
case IREP_TT_INT64:
|
154
|
+
#ifdef MRB_64BIT
|
120
155
|
{
|
121
|
-
|
122
|
-
|
123
|
-
|
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;
|
124
162
|
}
|
125
163
|
break;
|
164
|
+
#else
|
165
|
+
/* fall through */
|
166
|
+
#endif
|
167
|
+
case IREP_TT_INT32:
|
168
|
+
size += 4; /* 32bits = 4bytes */
|
169
|
+
break;
|
126
170
|
|
127
|
-
|
128
|
-
|
129
|
-
str = float_to_str(mrb, irep->pool[pool_no]);
|
171
|
+
case IREP_TT_FLOAT:
|
172
|
+
#ifndef MRB_NO_FLOAT
|
130
173
|
{
|
131
|
-
|
132
|
-
mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
|
133
|
-
size += (size_t)len;
|
174
|
+
size += sizeof(double);
|
134
175
|
}
|
135
|
-
break;
|
136
176
|
#endif
|
177
|
+
break;
|
137
178
|
|
138
|
-
|
179
|
+
default: /* packed IREP_TT_STRING */
|
139
180
|
{
|
140
|
-
mrb_int len =
|
181
|
+
mrb_int len = irep->pool[pool_no].tt >> 2; /* unpack length */
|
141
182
|
mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
|
142
|
-
size += (
|
183
|
+
size += sizeof(uint16_t);
|
184
|
+
size += (size_t)len+1;
|
143
185
|
}
|
144
186
|
break;
|
145
|
-
|
146
|
-
default:
|
147
|
-
break;
|
148
187
|
}
|
149
188
|
mrb_gc_arena_restore(mrb, ai);
|
150
189
|
}
|
@@ -153,52 +192,63 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep)
|
|
153
192
|
}
|
154
193
|
|
155
194
|
static ptrdiff_t
|
156
|
-
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)
|
157
196
|
{
|
158
197
|
int pool_no;
|
159
198
|
uint8_t *cur = buf;
|
160
|
-
|
161
|
-
|
162
|
-
const char *char_ptr;
|
199
|
+
mrb_int len;
|
200
|
+
const char *ptr;
|
163
201
|
|
164
|
-
cur +=
|
202
|
+
cur += uint16_to_bin(irep->plen, cur); /* number of pool */
|
165
203
|
|
166
204
|
for (pool_no = 0; pool_no < irep->plen; pool_no++) {
|
167
205
|
int ai = mrb_gc_arena_save(mrb);
|
168
206
|
|
169
|
-
switch (
|
170
|
-
|
171
|
-
|
172
|
-
|
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 */
|
173
227
|
break;
|
174
228
|
|
175
|
-
|
176
|
-
case MRB_TT_FLOAT:
|
229
|
+
case IREP_TT_FLOAT:
|
177
230
|
cur += uint8_to_bin(IREP_TT_FLOAT, cur); /* data type */
|
178
|
-
|
179
|
-
|
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 */
|
180
238
|
#endif
|
181
|
-
|
182
|
-
case MRB_TT_STRING:
|
183
|
-
cur += uint8_to_bin(IREP_TT_STRING, cur); /* data type */
|
184
|
-
str = irep->pool[pool_no];
|
185
239
|
break;
|
186
240
|
|
187
|
-
default:
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
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;
|
196
251
|
}
|
197
|
-
|
198
|
-
cur += uint16_to_bin(len, cur); /* data length */
|
199
|
-
memcpy(cur, char_ptr, (size_t)len);
|
200
|
-
cur += len;
|
201
|
-
|
202
252
|
mrb_gc_arena_restore(mrb, ai);
|
203
253
|
}
|
204
254
|
|
@@ -207,13 +257,13 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
|
|
207
257
|
|
208
258
|
|
209
259
|
static size_t
|
210
|
-
get_syms_block_size(mrb_state *mrb, mrb_irep *irep)
|
260
|
+
get_syms_block_size(mrb_state *mrb, const mrb_irep *irep)
|
211
261
|
{
|
212
262
|
size_t size = 0;
|
213
263
|
int sym_no;
|
214
264
|
mrb_int len;
|
215
265
|
|
216
|
-
size += sizeof(
|
266
|
+
size += sizeof(uint16_t); /* slen */
|
217
267
|
for (sym_no = 0; sym_no < irep->slen; sym_no++) {
|
218
268
|
size += sizeof(uint16_t); /* snl(n) */
|
219
269
|
if (irep->syms[sym_no] != 0) {
|
@@ -226,13 +276,13 @@ get_syms_block_size(mrb_state *mrb, mrb_irep *irep)
|
|
226
276
|
}
|
227
277
|
|
228
278
|
static ptrdiff_t
|
229
|
-
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)
|
230
280
|
{
|
231
281
|
int sym_no;
|
232
282
|
uint8_t *cur = buf;
|
233
283
|
const char *name;
|
234
284
|
|
235
|
-
cur +=
|
285
|
+
cur += uint16_to_bin(irep->slen, cur); /* number of symbol */
|
236
286
|
|
237
287
|
for (sym_no = 0; sym_no < irep->slen; sym_no++) {
|
238
288
|
if (irep->syms[sym_no] != 0) {
|
@@ -255,7 +305,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
|
|
255
305
|
}
|
256
306
|
|
257
307
|
static size_t
|
258
|
-
get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep)
|
308
|
+
get_irep_record_size_1(mrb_state *mrb, const mrb_irep *irep)
|
259
309
|
{
|
260
310
|
size_t size = 0;
|
261
311
|
|
@@ -267,7 +317,7 @@ get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep)
|
|
267
317
|
}
|
268
318
|
|
269
319
|
static size_t
|
270
|
-
get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
|
320
|
+
get_irep_record_size(mrb_state *mrb, const mrb_irep *irep)
|
271
321
|
{
|
272
322
|
size_t size = 0;
|
273
323
|
int irep_no;
|
@@ -280,7 +330,7 @@ get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
|
|
280
330
|
}
|
281
331
|
|
282
332
|
static int
|
283
|
-
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)
|
284
334
|
{
|
285
335
|
int i;
|
286
336
|
uint8_t *src = bin;
|
@@ -289,11 +339,6 @@ write_irep_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *irep_rec
|
|
289
339
|
return MRB_DUMP_INVALID_IREP;
|
290
340
|
}
|
291
341
|
|
292
|
-
*irep_record_size = get_irep_record_size_1(mrb, irep);
|
293
|
-
if (*irep_record_size == 0) {
|
294
|
-
return MRB_DUMP_GENERAL_FAILURE;
|
295
|
-
}
|
296
|
-
|
297
342
|
bin += write_irep_header(mrb, irep, bin);
|
298
343
|
bin += write_iseq_block(mrb, irep, bin, flags);
|
299
344
|
bin += write_pool_block(mrb, irep, bin);
|
@@ -341,7 +386,7 @@ write_section_irep_header(mrb_state *mrb, size_t section_size, uint8_t *bin)
|
|
341
386
|
}
|
342
387
|
|
343
388
|
static int
|
344
|
-
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)
|
345
390
|
{
|
346
391
|
int result;
|
347
392
|
size_t rsize = 0;
|
@@ -357,6 +402,7 @@ write_section_irep(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *len_p,
|
|
357
402
|
if (result != MRB_DUMP_OK) {
|
358
403
|
return result;
|
359
404
|
}
|
405
|
+
mrb_assert(rsize == get_irep_record_size(mrb, irep));
|
360
406
|
*len_p = cur - bin + rsize;
|
361
407
|
write_section_irep_header(mrb, *len_p, bin);
|
362
408
|
|
@@ -364,7 +410,7 @@ write_section_irep(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, size_t *len_p,
|
|
364
410
|
}
|
365
411
|
|
366
412
|
static size_t
|
367
|
-
get_debug_record_size(mrb_state *mrb, mrb_irep *irep)
|
413
|
+
get_debug_record_size(mrb_state *mrb, const mrb_irep *irep)
|
368
414
|
{
|
369
415
|
size_t ret = 0;
|
370
416
|
uint16_t f_idx;
|
@@ -413,11 +459,11 @@ find_filename_index(const mrb_sym *ary, int ary_len, mrb_sym s)
|
|
413
459
|
}
|
414
460
|
|
415
461
|
static size_t
|
416
|
-
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)
|
417
463
|
{
|
418
464
|
mrb_sym *filenames = *fp;
|
419
465
|
size_t size = 0;
|
420
|
-
mrb_irep_debug_info *di = irep->debug_info;
|
466
|
+
const mrb_irep_debug_info *di = irep->debug_info;
|
421
467
|
int i;
|
422
468
|
|
423
469
|
mrb_assert(lp);
|
@@ -444,7 +490,7 @@ get_filename_table_size(mrb_state *mrb, mrb_irep *irep, mrb_sym **fp, uint16_t *
|
|
444
490
|
}
|
445
491
|
|
446
492
|
static size_t
|
447
|
-
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)
|
448
494
|
{
|
449
495
|
uint8_t *cur;
|
450
496
|
uint16_t f_idx;
|
@@ -498,7 +544,7 @@ write_debug_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const
|
|
498
544
|
}
|
499
545
|
|
500
546
|
static size_t
|
501
|
-
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)
|
502
548
|
{
|
503
549
|
size_t size, len;
|
504
550
|
int irep_no;
|
@@ -516,7 +562,7 @@ write_debug_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const*
|
|
516
562
|
}
|
517
563
|
|
518
564
|
static int
|
519
|
-
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)
|
520
566
|
{
|
521
567
|
size_t section_size = 0;
|
522
568
|
const uint8_t *bin = cur;
|
@@ -566,7 +612,7 @@ create_lv_sym_table(mrb_state *mrb, const mrb_irep *irep, mrb_sym **syms, uint32
|
|
566
612
|
}
|
567
613
|
|
568
614
|
for (i = 0; i + 1 < irep->nlocals; ++i) {
|
569
|
-
mrb_sym const name = irep->lv[i]
|
615
|
+
mrb_sym const name = irep->lv[i];
|
570
616
|
if (name == 0) continue;
|
571
617
|
if (find_filename_index(*syms, *syms_len, name) != -1) continue;
|
572
618
|
|
@@ -609,16 +655,14 @@ write_lv_record(mrb_state *mrb, const mrb_irep *irep, uint8_t **start, mrb_sym c
|
|
609
655
|
int i;
|
610
656
|
|
611
657
|
for (i = 0; i + 1 < irep->nlocals; ++i) {
|
612
|
-
if (irep->lv[i]
|
658
|
+
if (irep->lv[i] == 0) {
|
613
659
|
cur += uint16_to_bin(RITE_LV_NULL_MARK, cur);
|
614
|
-
cur += uint16_to_bin(0, cur);
|
615
660
|
}
|
616
661
|
else {
|
617
|
-
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]);
|
618
663
|
mrb_assert(sym_idx != -1); /* local variable name must be in syms */
|
619
664
|
|
620
665
|
cur += uint16_to_bin(sym_idx, cur);
|
621
|
-
cur += uint16_to_bin(irep->lv[i].r, cur);
|
622
666
|
}
|
623
667
|
}
|
624
668
|
|
@@ -632,12 +676,12 @@ write_lv_record(mrb_state *mrb, const mrb_irep *irep, uint8_t **start, mrb_sym c
|
|
632
676
|
}
|
633
677
|
|
634
678
|
static size_t
|
635
|
-
get_lv_record_size(mrb_state *mrb, mrb_irep *irep)
|
679
|
+
get_lv_record_size(mrb_state *mrb, const mrb_irep *irep)
|
636
680
|
{
|
637
681
|
size_t ret = 0;
|
638
682
|
int i;
|
639
683
|
|
640
|
-
ret +=
|
684
|
+
ret += sizeof(uint16_t) * (irep->nlocals - 1);
|
641
685
|
|
642
686
|
for (i = 0; i < irep->rlen; ++i) {
|
643
687
|
ret += get_lv_record_size(mrb, irep->reps[i]);
|
@@ -647,7 +691,7 @@ get_lv_record_size(mrb_state *mrb, mrb_irep *irep)
|
|
647
691
|
}
|
648
692
|
|
649
693
|
static size_t
|
650
|
-
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)
|
651
695
|
{
|
652
696
|
size_t ret = 0, i;
|
653
697
|
|
@@ -665,7 +709,7 @@ get_lv_section_size(mrb_state *mrb, mrb_irep *irep, mrb_sym const *syms, uint32_
|
|
665
709
|
}
|
666
710
|
|
667
711
|
static int
|
668
|
-
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)
|
669
713
|
{
|
670
714
|
uint8_t *cur = start;
|
671
715
|
struct rite_section_lv_header *header;
|
@@ -703,25 +747,20 @@ static int
|
|
703
747
|
write_rite_binary_header(mrb_state *mrb, size_t binary_size, uint8_t *bin, uint8_t flags)
|
704
748
|
{
|
705
749
|
struct rite_binary_header *header = (struct rite_binary_header *)bin;
|
706
|
-
uint16_t crc;
|
707
|
-
uint32_t offset;
|
708
750
|
|
709
751
|
memcpy(header->binary_ident, RITE_BINARY_IDENT, sizeof(header->binary_ident));
|
710
|
-
memcpy(header->
|
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));
|
711
754
|
memcpy(header->compiler_name, RITE_COMPILER_NAME, sizeof(header->compiler_name));
|
712
755
|
memcpy(header->compiler_version, RITE_COMPILER_VERSION, sizeof(header->compiler_version));
|
713
756
|
mrb_assert(binary_size <= UINT32_MAX);
|
714
757
|
uint32_to_bin((uint32_t)binary_size, header->binary_size);
|
715
758
|
|
716
|
-
offset = (uint32_t)((&(header->binary_crc[0]) - bin) + sizeof(uint16_t));
|
717
|
-
crc = calc_crc_16_ccitt(bin + offset, binary_size - offset, 0);
|
718
|
-
uint16_to_bin(crc, header->binary_crc);
|
719
|
-
|
720
759
|
return MRB_DUMP_OK;
|
721
760
|
}
|
722
761
|
|
723
762
|
static mrb_bool
|
724
|
-
debug_info_defined_p(mrb_irep *irep)
|
763
|
+
debug_info_defined_p(const mrb_irep *irep)
|
725
764
|
{
|
726
765
|
int i;
|
727
766
|
|
@@ -733,7 +772,7 @@ debug_info_defined_p(mrb_irep *irep)
|
|
733
772
|
}
|
734
773
|
|
735
774
|
static mrb_bool
|
736
|
-
lv_defined_p(mrb_irep *irep)
|
775
|
+
lv_defined_p(const mrb_irep *irep)
|
737
776
|
{
|
738
777
|
int i;
|
739
778
|
|
@@ -747,7 +786,7 @@ lv_defined_p(mrb_irep *irep)
|
|
747
786
|
}
|
748
787
|
|
749
788
|
static int
|
750
|
-
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)
|
751
790
|
{
|
752
791
|
int result = MRB_DUMP_GENERAL_FAILURE;
|
753
792
|
size_t malloc_size;
|
@@ -835,15 +874,15 @@ error_exit:
|
|
835
874
|
}
|
836
875
|
|
837
876
|
int
|
838
|
-
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)
|
839
878
|
{
|
840
879
|
return dump_irep(mrb, irep, flags, bin, bin_size);
|
841
880
|
}
|
842
881
|
|
843
|
-
#ifndef
|
882
|
+
#ifndef MRB_NO_STDIO
|
844
883
|
|
845
884
|
int
|
846
|
-
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)
|
847
886
|
{
|
848
887
|
uint8_t *bin = NULL;
|
849
888
|
size_t bin_size = 0;
|
@@ -865,7 +904,7 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
|
|
865
904
|
}
|
866
905
|
|
867
906
|
int
|
868
|
-
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)
|
869
908
|
{
|
870
909
|
uint8_t *bin = NULL;
|
871
910
|
size_t bin_size = 0, bin_idx = 0;
|
@@ -884,15 +923,8 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
|
|
884
923
|
"#ifdef __cplusplus\n"
|
885
924
|
"extern const uint8_t %s[];\n"
|
886
925
|
"#endif\n"
|
887
|
-
"const uint8_t
|
888
|
-
|
889
|
-
"__attribute__((aligned(%u)))\n"
|
890
|
-
"#elif defined _MSC_VER\n"
|
891
|
-
"__declspec(align(%u))\n"
|
892
|
-
"#endif\n"
|
893
|
-
"%s[] = {",
|
894
|
-
initname,
|
895
|
-
(uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) {
|
926
|
+
"const uint8_t %s[] = {",
|
927
|
+
initname, initname) < 0) {
|
896
928
|
mrb_free(mrb, bin);
|
897
929
|
return MRB_DUMP_WRITE_FAULT;
|
898
930
|
}
|
@@ -918,4 +950,297 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
|
|
918
950
|
return result;
|
919
951
|
}
|
920
952
|
|
921
|
-
|
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 */
|