This is to keep the local variables of the previously created blocks consistent in case the `mrbc_context` passed to `mrb_load_exec()` is `NULL` or different.
Switching between `mrbc_context` pointers that are non `NULL` can be done safely by calling `mrbc_cleanup_local_variables()`.
Before this patch, the result of the following code is not as expected.
```console
% cat loadstr.c
#include <mruby.h>
#include <mruby/compile.h>
int
main(int argc, char *argv[])
{
mrb_state *mrb = mrb_open();
mrb_load_string(
mrb,
"(a, b, c, d, e, f, g) = [1, 2, 3, 4, 5, 6, 7] \n"
"$lambda = -> { p [a, b, c, d, e, f, g] }");
mrb_load_string(mrb, "$lambda.call");
mrb_close(mrb);
return 0;
}
% $(bin/mruby-config --cc --cflags --ldflags) loadstr.c $(bin/mruby-config --libs) && ./a.out
[main, nil, nil, main, nil, nil, main]
```
Also, since `mrb_env_unshare()` was not used before, the internal stack of simply detached `env` objects could show invalid addresses by `stack_extend()`.
ref. https://github.com/kou/mruby-pp/commit/ef5951aca870183d8767cb61f6414240988ca35e
Transforms the value of a splat inside a return statement (similar
to an array). For example, `return *nil` should return `nil.to_a`,
while `return *1` should return `[1]`
- mrb_div_int() does integer division in Ruby way (mdiv)
returns mrb_int
- mrb_div_int_value() division with zero div and overflow checks.
returns mrb_value
- remove `lex_strterm_before_heredoc` that does not nest
- remove `all_heredocs` that cannot distinguish nested and followed
here-doc
- replace `lex_strterm` represented by cons list by C struct
- push/pop `lex_strterm` before/after interpolation
At the same time, the saving and restoration of unwanted object arenas was removed.
In addition, the common code to extend the pool that existed before has been grouped together and newly established as `lit_pool_extend()`.
Note that previously the variable `i` was updated at that time, but since it is the same as the value at the end of a `for` statement, it has been omitted.
The original catalyst was that `bin/mrbc` with the `MRB_WORD_BOXING` + not `MRB_BOXWORD_NO_FLOAT_TRUNCATE` configuration caused `bin/mrbtest` with the `MRB_NO_BOXING` configuration to fail.
Upon investigation, I concluded that avoiding the creation of temporary objects would prevent the truncation of floating point numbers.
Therefore, this patch also prevents the `rake test` from failing with the following configuration.
```console
% cat test_config.rb
bootstrap_mrbc = nil
MRuby::Build.new do |conf|
conf.toolchain
conf.enable_debug
conf.enable_test
conf.disable_presym
conf.defines << %w(MRB_WORD_BOXING)
#conf.defines << %w(MRB_WORDBOX_NO_FLOAT_TRUNCATE)
gem core: "mruby-bin-mrbc"
gem core: "mruby-kernel-ext"
bootstrap_mrbc = File.join(conf.build_dir, "bin/mrbc")
end
MRuby::Build.new("nobox") do |conf|
conf.toolchain
conf.enable_debug
conf.enable_test
conf.defines << %(MRB_NO_BOXING)
conf.mrbcfile = bootstrap_mrbc
gem core: "mruby-kernel-ext"
end
```
Internal functions can only be called from within the library.
Functions listed in `mruby/internal.h` can be called from:
* core (src/*.c)
* gems (mrbgems/**/*.c)
But not from the application linked with `libmruby`.