mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: refactored compile_return
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bdac4b6ee9
commit
ae49dbd392
1 changed files with 15 additions and 9 deletions
24
compile.c
24
compile.c
|
@ -5109,20 +5109,26 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
|
|||
|
||||
if (iseq) {
|
||||
enum iseq_type type = iseq->body->type;
|
||||
const rb_iseq_t *parent_iseq = iseq->body->parent_iseq;
|
||||
enum iseq_type parent_type;
|
||||
const rb_iseq_t *is = iseq;
|
||||
enum iseq_type t = type;
|
||||
const NODE *retval = node->nd_stts;
|
||||
LABEL *splabel = 0;
|
||||
|
||||
if (type == ISEQ_TYPE_TOP) {
|
||||
retval = 0;
|
||||
type = ISEQ_TYPE_METHOD;
|
||||
while (t == ISEQ_TYPE_RESCUE || t == ISEQ_TYPE_ENSURE) {
|
||||
if (!(is = is->body->parent_iseq)) break;
|
||||
t = is->body->type;
|
||||
}
|
||||
else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE || type == ISEQ_TYPE_MAIN) &&
|
||||
parent_iseq &&
|
||||
((parent_type = parent_iseq->body->type) == ISEQ_TYPE_TOP ||
|
||||
parent_type == ISEQ_TYPE_MAIN)) {
|
||||
switch (t) {
|
||||
case ISEQ_TYPE_TOP:
|
||||
case ISEQ_TYPE_MAIN:
|
||||
if (is == iseq) {
|
||||
/* plain top-level, leave directly */
|
||||
type = ISEQ_TYPE_METHOD;
|
||||
}
|
||||
retval = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (type == ISEQ_TYPE_METHOD) {
|
||||
|
|
Loading…
Add table
Reference in a new issue