From 74ca6b88dd9673d2a47ce4bbfd9214dcea5ee366 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 17 Aug 2019 23:33:12 +0900 Subject: Omit a tag unless loading with a wrapper module --- load.c | 24 +++++++++++++----------- 1 file 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 -- cgit v1.2.3