ruby-changes:67393
From: Nobuyoshi <ko1@a...>
Date: Tue, 31 Aug 2021 15:32:53 +0900 (JST)
Subject: [ruby-changes:67393] d23264d359 (master): Extract compile_block from iseq_compile_each0
https://git.ruby-lang.org/ruby.git/commit/?id=d23264d359 From d23264d35932f7154922017b2701ce3bdb8fec8b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 31 Aug 2021 11:39:59 +0900 Subject: Extract compile_block from iseq_compile_each0 And constify `node` argument of `iseq_compile_each0`. --- compile.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/compile.c b/compile.c index 7976bd0..8120af3 100644 --- a/compile.c +++ b/compile.c @@ -3936,6 +3936,20 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons https://github.com/ruby/ruby/blob/trunk/compile.c#L3936 } static int +compile_block(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped) +{ + while (node && nd_type(node) == NODE_BLOCK) { + CHECK(COMPILE_(ret, "BLOCK body", node->nd_head, + (node->nd_next ? 1 : popped))); + node = node->nd_next; + } + if (node) { + CHECK(COMPILE_(ret, "BLOCK next", node->nd_next, popped)); + } + return COMPILE_OK; +} + +static int compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node) { int cnt; @@ -8104,7 +8118,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co https://github.com/ruby/ruby/blob/trunk/compile.c#L8118 } -static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped); +static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped); /** compile each node @@ -8142,7 +8156,7 @@ check_yield_place(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L8156 } static int -iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped) +iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped) { const int line = (int)nd_line(node); const NODE *const line_node = node; @@ -8168,17 +8182,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in https://github.com/ruby/ruby/blob/trunk/compile.c#L8182 #define BEFORE_RETURN debug_node_end() switch (type) { - case NODE_BLOCK:{ - while (node && nd_type(node) == NODE_BLOCK) { - CHECK(COMPILE_(ret, "BLOCK body", node->nd_head, - (node->nd_next ? 1 : popped))); - node = node->nd_next; - } - if (node) { - CHECK(COMPILE_(ret, "BLOCK next", node->nd_next, popped)); - } + case NODE_BLOCK: + CHECK(compile_block(iseq, ret, node, popped)); break; - } case NODE_IF: case NODE_UNLESS: CHECK(compile_if(iseq, ret, node, popped, type)); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/