ruby-changes:67530
From: Nobuyoshi <ko1@a...>
Date: Wed, 1 Sep 2021 16:17:27 +0900 (JST)
Subject: [ruby-changes:67530] cbf841e3ed (master): Extract compile_errinfo from iseq_compile_each0
https://git.ruby-lang.org/ruby.git/commit/?id=cbf841e3ed From cbf841e3ed511123ba0457f3fc6b4c85ca075bd0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 13 Mar 2017 00:03:09 +0900 Subject: Extract compile_errinfo from iseq_compile_each0 --- compile.c | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/compile.c b/compile.c index 00bc395..ee2507d 100644 --- a/compile.c +++ b/compile.c @@ -8802,6 +8802,34 @@ compile_dots(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8802 return COMPILE_OK; } +static int +compile_errinfo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped) +{ + if (!popped) { + if (iseq->body->type == ISEQ_TYPE_RESCUE) { + ADD_GETLOCAL(ret, node, LVAR_ERRINFO, 0); + } + else { + const rb_iseq_t *ip = iseq; + int level = 0; + while (ip) { + if (ip->body->type == ISEQ_TYPE_RESCUE) { + break; + } + ip = ip->body->parent_iseq; + level++; + } + if (ip) { + ADD_GETLOCAL(ret, node, LVAR_ERRINFO, level); + } + else { + ADD_INSN(ret, node, putnil); + } + } + } + return COMPILE_OK; +} + static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped); /** compile each node @@ -9458,31 +9486,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no https://github.com/ruby/ruby/blob/trunk/compile.c#L9486 } break; } - case NODE_ERRINFO:{ - if (!popped) { - if (body->type == ISEQ_TYPE_RESCUE) { - ADD_GETLOCAL(ret, node, LVAR_ERRINFO, 0); - } - else { - const rb_iseq_t *ip = iseq; - int level = 0; - while (ip) { - if (ip->body->type == ISEQ_TYPE_RESCUE) { - break; - } - ip = ip->body->parent_iseq; - level++; - } - if (ip) { - ADD_GETLOCAL(ret, node, LVAR_ERRINFO, level); - } - else { - ADD_INSN(ret, node, putnil); - } - } - } + case NODE_ERRINFO: + CHECK(compile_errinfo(iseq, ret, node, popped)); break; - } case NODE_DEFINED: if (!popped) { CHECK(compile_defined_expr(iseq, ret, node, Qtrue)); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/