Extract compile_block from iseq_compile_each0
And constify `node` argument of `iseq_compile_each0`.
This commit is contained in:
parent
80309800f1
commit
d23264d359
30
compile.c
30
compile.c
@ -3935,6 +3935,20 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
|
|||||||
return COMPILE_OK;
|
return COMPILE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static int
|
||||||
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
|
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
|
||||||
{
|
{
|
||||||
@ -8104,7 +8118,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
compile each node
|
||||||
|
|
||||||
@ -8142,7 +8156,7 @@ check_yield_place(const rb_iseq_t *iseq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 int line = (int)nd_line(node);
|
||||||
const NODE *const line_node = 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
|
|||||||
#define BEFORE_RETURN debug_node_end()
|
#define BEFORE_RETURN debug_node_end()
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NODE_BLOCK:{
|
case NODE_BLOCK:
|
||||||
while (node && nd_type(node) == NODE_BLOCK) {
|
CHECK(compile_block(iseq, ret, node, popped));
|
||||||
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));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case NODE_IF:
|
case NODE_IF:
|
||||||
case NODE_UNLESS:
|
case NODE_UNLESS:
|
||||||
CHECK(compile_if(iseq, ret, node, popped, type));
|
CHECK(compile_if(iseq, ret, node, popped, type));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user