aboutsummaryrefslogtreecommitdiffstats
path: root/load.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-17 23:33:12 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-18 00:34:12 +0900
commit74ca6b88dd9673d2a47ce4bbfd9214dcea5ee366 (patch)
tree865418ee81988a0a2eed41a01b0e2fe32b3bc2bb /load.c
parent1d11a8b1938d3310d6b573c2feb173661a82b6a6 (diff)
downloadruby-74ca6b88dd9673d2a47ce4bbfd9214dcea5ee366.tar.gz
Omit a tag unless loading with a wrapper module
Diffstat (limited to 'load.c')
-rw-r--r--load.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/load.c b/load.c
index c3d1d63aeb..6ebe8e5982 100644
--- a/load.c
+++ b/load.c
@@ -587,7 +587,7 @@ load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
}
static inline enum ruby_tag_type
-rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
+load_wrapping(rb_execution_context_t *ec, VALUE fname)
{
enum ruby_tag_type state;
rb_thread_t *th = rb_ec_thread_ptr(ec);
@@ -599,15 +599,10 @@ rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
ec->errinfo = Qnil; /* ensure */
- if (!wrap) {
- th->top_wrapper = 0;
- }
- else {
- /* load in anonymous module as toplevel */
- th->top_self = rb_obj_clone(rb_vm_top_self());
- th->top_wrapper = rb_module_new();
- rb_extend_object(th->top_self, th->top_wrapper);
- }
+ /* load in anonymous module as toplevel */
+ th->top_self = rb_obj_clone(rb_vm_top_self());
+ th->top_wrapper = rb_module_new();
+ rb_extend_object(th->top_self, th->top_wrapper);
EC_PUSH_TAG(ec);
state = EC_EXEC_TAG();
@@ -641,7 +636,14 @@ static void
rb_load_internal(VALUE fname, int wrap)
{
rb_execution_context_t *ec = GET_EC();
- raise_load_if_failed(ec, rb_load_internal0(ec, fname, wrap));
+ enum ruby_tag_type state = TAG_NONE;
+ if (wrap) {
+ state = load_wrapping(ec, fname);
+ }
+ else {
+ load_iseq_eval(ec, fname);
+ }
+ raise_load_if_failed(ec, state);
}
void