From 846ca98acfdc83f645e619ff8d9f1f794dcc7adc Mon Sep 17 00:00:00 2001 From: yugui Date: Sat, 27 Dec 2008 02:16:28 +0000 Subject: merges r21079 from trunk into ruby_1_9_1. * vm.c (Init_VM): create and define TOPLEVEL_BINDING at first. * vm.c (vm_set_main_stack, rb_iseq_eval_main): added. * parse.y (rb_parser_compile_file): fix to check parse_in_eval flag. * eval.c (ruby_exec_node): use rb_iseq_eval_main() instead of rb_iseq_eval(). * iseq.c (rb_iseq_new_main), vm_core.h: added. main script (specified by -e or script name) should be run under TOPLEVEL_BINDING using Kernel#eval. Above changes simulate Kernel#eval behaviour. [ruby-dev:37240] * compile.c (make_name_for_block): skip iseq except block type. this fix is needed for [ruby-dev:37240], and also fixes [ruby-dev:35392]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 30029ed98a..951d1c0076 100644 --- a/compile.c +++ b/compile.c @@ -2724,16 +2724,22 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, static VALUE make_name_for_block(rb_iseq_t *iseq) { - if (iseq->parent_iseq == 0) { - return rb_sprintf("block in %s", RSTRING_PTR(iseq->name)); - } - else { - int level = 1; - rb_iseq_t *ip = iseq; + int level = 1; + rb_iseq_t *ip = iseq; + + if (iseq->parent_iseq != 0) { while (ip->local_iseq != ip) { + if (ip->type == ISEQ_TYPE_BLOCK) { + level++; + } ip = ip->parent_iseq; - level++; } + } + + if (level == 1) { + return rb_sprintf("block in %s", RSTRING_PTR(ip->name)); + } + else { return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->name)); } } @@ -5323,5 +5329,3 @@ rb_parse_in_eval(void) { return GET_THREAD()->parse_in_eval != 0; } - - -- cgit v1.2.3