diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-09-10 18:12:38 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-10 18:12:38 +0900 |
| commit | c27e45193177b6e4d09d526a248af63c0961035a (patch) | |
| tree | 863c5082109295c880311b2abe1eefc4c748dc4d /lib | |
| parent | c345fe432171cc2b90b614a0b44305b218090de6 (diff) | |
| parent | 9840e5352b2abf96235068f0e9d08f14b1d333cf (diff) | |
| download | mruby-c27e45193177b6e4d09d526a248af63c0961035a.tar.gz mruby-c27e45193177b6e4d09d526a248af63c0961035a.zip | |
Merge pull request #4933 from dearblue/variables
Fix take over file scope variables with `mruby` and `mirb` command
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mruby/gem.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index 4c3cd7f02..6fcaad9c1 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -180,6 +180,7 @@ module MRuby f.puts %Q[] f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {] f.puts %Q[ int ai = mrb_gc_arena_save(mrb);] + f.puts %Q[ struct REnv *e;] unless rbfiles.empty? f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")] unless rbfiles.empty? f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});] @@ -188,6 +189,9 @@ module MRuby f.puts %Q[ mrb_close(mrb);] f.puts %Q[ exit(EXIT_FAILURE);] f.puts %Q[ }] + f.puts %Q[ e = mrb->c->cibase->env;] + f.puts %Q[ mrb->c->cibase->env = NULL;] + f.puts %Q[ mrb_env_unshare(mrb, e);] end f.puts %Q[ mrb_gc_arena_restore(mrb, ai);] f.puts %Q[}] @@ -214,6 +218,7 @@ module MRuby f.puts %Q[#include <stdlib.h>] unless rbfiles.empty? f.puts %Q[#include <mruby.h>] f.puts %Q[#include <mruby/irep.h>] unless rbfiles.empty? + f.puts %Q[#include <mruby/proc.h>] unless rbfiles.empty? end def print_gem_test_header(f) |
