From f0d63c81e311eeaccb8850c1591dcd32fc372c65 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 28 Dec 2008 09:40:46 +0000 Subject: merges r21088 from trunk into ruby_1_(_1. * iseq.h, iseq.c (rb_iseq_new_main): add a type ISEQ_TYPE_MAIN. [ruby-dev:37619] * compile.c (rb_dvar_defined, ruby_iseq_compile): ditto. * iseq.c (iseq_data_to_ary, iseq_load): ditto. * compile.c (iseq_compile_each): fix to check ip->compile_data. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 951d1c007..f459eb3cd 100644 --- a/compile.c +++ b/compile.c @@ -469,6 +469,7 @@ ruby_iseq_compile(VALUE self, NODE *node) case ISEQ_TYPE_CLASS: case ISEQ_TYPE_BLOCK: case ISEQ_TYPE_EVAL: + case ISEQ_TYPE_MAIN: case ISEQ_TYPE_TOP: rb_compile_error(ERROR_ARGS "compile/should not be reached: %s:%d", __FILE__, __LINE__); @@ -3265,6 +3266,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else { rb_iseq_t *ip = iseq->parent_iseq; while (ip) { + if (!ip->compile_data) { + ip = 0; + break; + } + level++; if (ip->compile_data->redo_label != 0) { level = 0x8000; @@ -3281,6 +3287,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else if (ip->type == ISEQ_TYPE_EVAL) { goto break_in_eval; } + ip = ip->parent_iseq; } COMPILE_ERROR((ERROR_ARGS "Invalid break")); @@ -3322,6 +3329,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) rb_iseq_t *ip; ip = iseq; while (ip) { + if (!ip->compile_data) { + ip = 0; + break; + } + level = 0x8000 | 0x4000; if (ip->compile_data->redo_label != 0) { /* while loop */ @@ -3333,6 +3345,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else if (ip->type == ISEQ_TYPE_EVAL) { goto next_in_eval; } + ip = ip->parent_iseq; } if (ip != 0) { @@ -3383,6 +3396,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) level = 0x8000 | 0x4000; ip = iseq; while (ip) { + if (!ip->compile_data) { + ip = 0; + break; + } + if (ip->compile_data->redo_label != 0) { break; } @@ -3392,6 +3410,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else if (ip->type == ISEQ_TYPE_EVAL) { goto redo_in_eval; } + ip = ip->parent_iseq; } if (ip != 0) { @@ -5291,7 +5310,9 @@ rb_dvar_defined(ID id) while (iseq->type == ISEQ_TYPE_BLOCK || iseq->type == ISEQ_TYPE_RESCUE || iseq->type == ISEQ_TYPE_ENSURE || - iseq->type == ISEQ_TYPE_EVAL) { + iseq->type == ISEQ_TYPE_EVAL || + iseq->type == ISEQ_TYPE_MAIN + ) { int i; for (i = 0; i < iseq->local_table_size; i++) { -- cgit