summaryrefslogtreecommitdiff
path: root/eval_load.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-25 16:29:26 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-25 16:29:26 +0000
commit9987d53e519cf84fe47ffbbd4f48be0bc40938c7 (patch)
tree1cbd036967f588026bf6038c39898fa20a531e4b /eval_load.c
parente98f7e1eaa18c33d211e6a0cf245eaf4b175c3c7 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@11884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_load.c')
-rw-r--r--eval_load.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/eval_load.c b/eval_load.c
index 321fc31093..debc2412e3 100644
--- a/eval_load.c
+++ b/eval_load.c
@@ -136,7 +136,7 @@ rb_load_internal(char *file)
}
iseq = rb_iseq_new(node, rb_str_new2("<top (required)>"),
- rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
+ rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
rb_thread_eval(GET_THREAD(), iseq);
return 0;
@@ -147,7 +147,9 @@ rb_load(VALUE fname, int wrap)
{
VALUE tmp;
int state;
- volatile VALUE self = ruby_top_self;
+ rb_thread_t *th = GET_THREAD();
+ VALUE wrapper = th->top_wrapper;
+ VALUE self = th->top_self;
FilePathValue(fname);
fname = rb_str_new4(fname);
@@ -157,14 +159,17 @@ rb_load(VALUE fname, int wrap)
}
fname = tmp;
- GET_THREAD()->errinfo = Qnil; /* ensure */
-
+ th->errinfo = Qnil; /* ensure */
+
if (!wrap) {
rb_secure(4); /* should alter global state */
+ th->top_wrapper = 0;
}
else {
/* load in anonymous module as toplevel */
- self = rb_obj_clone(ruby_top_self);
+ th->top_self = rb_obj_clone(ruby_top_self);
+ th->top_wrapper = rb_module_new();
+ rb_extend_object(th->top_self, th->top_wrapper);
}
PUSH_TAG(PROT_NONE);
@@ -174,6 +179,9 @@ rb_load(VALUE fname, int wrap)
}
POP_TAG();
+ th->top_self = self;
+ th->top_wrapper = wrapper;
+
if (ruby_nerrs > 0) {
ruby_nerrs = 0;
rb_exc_raise(GET_THREAD()->errinfo);
@@ -184,7 +192,7 @@ rb_load(VALUE fname, int wrap)
if (!NIL_P(GET_THREAD()->errinfo)) {
/* exception during load */
- rb_exc_raise(GET_THREAD()->errinfo);
+ rb_exc_raise(th->errinfo);
}
}