1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: compile_evstr

* compile.c (compile_evstr): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-03-31 15:48:59 +00:00
parent 6b346a7c85
commit baabfa3fa2

View file

@ -5605,6 +5605,26 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
return COMPILE_OK;
}
static int
compile_evstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
CHECK(COMPILE_(ret, "nd_body", node, popped));
if (!popped && !all_string_result_p(node)) {
const int line = nd_line(node);
const unsigned int flag = VM_CALL_FCALL;
LABEL *isstr = NEW_LABEL(line);
ADD_INSN(ret, line, dup);
ADD_INSN2(ret, line, branchiftype, INT2FIX(T_STRING), isstr);
LABEL_REF(isstr);
ADD_INSN(ret, line, dup);
ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL);
ADD_INSN(ret, line, tostring);
ADD_LABEL(ret, isstr);
}
return COMPILE_OK;
}
static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped);
/**
compile each node
@ -6769,25 +6789,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
break;
}
case NODE_EVSTR:{
CHECK(COMPILE(ret, "nd_body", node->nd_body));
if (popped) {
ADD_INSN(ret, line, pop);
}
else if (!all_string_result_p(node->nd_body)) {
const unsigned int flag = VM_CALL_FCALL;
LABEL *isstr = NEW_LABEL(line);
ADD_INSN(ret, line, dup);
ADD_INSN2(ret, line, branchiftype, INT2FIX(T_STRING), isstr);
LABEL_REF(isstr);
ADD_INSN(ret, line, dup);
ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL);
ADD_INSN(ret, line, tostring);
ADD_LABEL(ret, isstr);
}
case NODE_EVSTR:
CHECK(compile_evstr(iseq, ret, node->nd_body, popped));
break;
}
case NODE_DREGX:{
compile_dregx(iseq, ret, node);