From 28defca799598e8ea8960fbbada49d94b5e6ac27 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 25 Feb 2007 16:29:26 +0000 Subject: * yarvcore.h: add rb_thread_t#top_wrapper, top_self. * eval_load.c (rb_load): support eval in wrapper module (load(file, true)). * eval.c: ditto. * eval_jump.h: ditto. * iseq.c: ditto. * vm.c: ditto. * yarvcore.c: ditto. * insns.def: add a empty line. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index eea1098c0..582450941 100644 --- a/eval.c +++ b/eval.c @@ -35,8 +35,6 @@ VALUE rb_eSysStackError; extern int ruby_nerrs; extern VALUE ruby_top_self; -static VALUE ruby_wrapper; /* security wrapper */ - static VALUE eval _((VALUE, VALUE, VALUE, char *, int)); static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int)); @@ -289,17 +287,20 @@ VALUE rb_eval_string_wrap(const char *str, int *state) { int status; - VALUE self = ruby_top_self; - VALUE wrapper = ruby_wrapper; + rb_thread_t *th = GET_THREAD(); + VALUE self = th->top_self; + VALUE wrapper = th->top_wrapper; VALUE val; - ruby_top_self = rb_obj_clone(ruby_top_self); - rb_extend_object(ruby_top_self, ruby_wrapper); + th->top_wrapper = rb_module_new(); + th->top_self = rb_obj_clone(ruby_top_self); + rb_extend_object(th->top_self, th->top_wrapper); val = rb_eval_string_protect(str, &status); - ruby_top_self = self; - ruby_wrapper = wrapper; + th->top_self = self; + th->top_wrapper = wrapper; + if (state) { *state = status; } @@ -2687,11 +2688,13 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj) static VALUE top_include(int argc, VALUE *argv, VALUE self) { + rb_thread_t *th = GET_THREAD(); + rb_secure(4); - if (ruby_wrapper) { + if (th->top_wrapper) { rb_warning ("main#include in the wrapped load is effective only in wrapper module"); - return rb_mod_include(argc, argv, ruby_wrapper); + return rb_mod_include(argc, argv, th->top_wrapper); } return rb_mod_include(argc, argv, rb_cObject); } -- cgit