зеркало из https://github.com/github/ruby.git
[PRISM] Remove dummy_line_node usage for break nodes
This commit is contained in:
Родитель
ffd9402c8d
Коммит
eb3bad1a0f
|
@ -4637,25 +4637,31 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PM_BREAK_NODE: {
|
case PM_BREAK_NODE: {
|
||||||
pm_break_node_t *break_node = (pm_break_node_t *) node;
|
// break
|
||||||
|
// ^^^^^
|
||||||
|
//
|
||||||
|
// break foo
|
||||||
|
// ^^^^^^^^^
|
||||||
|
const pm_break_node_t *cast = (const pm_break_node_t *) node;
|
||||||
unsigned long throw_flag = 0;
|
unsigned long throw_flag = 0;
|
||||||
|
|
||||||
if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0 && can_add_ensure_iseq(iseq)) {
|
if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0 && can_add_ensure_iseq(iseq)) {
|
||||||
/* while/until */
|
/* while/until */
|
||||||
LABEL *splabel = NEW_LABEL(0);
|
LABEL *splabel = NEW_LABEL(0);
|
||||||
ADD_LABEL(ret, splabel);
|
PUSH_LABEL(ret, splabel);
|
||||||
ADD_ADJUST(ret, &dummy_line_node, ISEQ_COMPILE_DATA(iseq)->redo_label);
|
PUSH_ADJUST(ret, location, ISEQ_COMPILE_DATA(iseq)->redo_label);
|
||||||
if (break_node->arguments) {
|
|
||||||
PM_COMPILE_NOT_POPPED((pm_node_t *)break_node->arguments);
|
if (cast->arguments != NULL) {
|
||||||
|
PM_COMPILE_NOT_POPPED((const pm_node_t *) cast->arguments);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PM_PUTNIL;
|
PUSH_INSN(ret, location, putnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_add_ensure_iseq(ret, iseq, 0, scope_node);
|
pm_add_ensure_iseq(ret, iseq, 0, scope_node);
|
||||||
ADD_INSNL(ret, &dummy_line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
|
PUSH_INSNL(ret, location, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
|
||||||
ADD_ADJUST_RESTORE(ret, splabel);
|
PUSH_ADJUST_RESTORE(ret, splabel);
|
||||||
|
if (!popped) PUSH_INSN(ret, location, putnil);
|
||||||
PM_PUTNIL_UNLESS_POPPED;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const rb_iseq_t *ip = iseq;
|
const rb_iseq_t *ip = iseq;
|
||||||
|
@ -4682,18 +4688,19 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* escape from block */
|
/* escape from block */
|
||||||
if (break_node->arguments) {
|
if (cast->arguments != NULL) {
|
||||||
PM_COMPILE_NOT_POPPED((pm_node_t *)break_node->arguments);
|
PM_COMPILE_NOT_POPPED((const pm_node_t *) cast->arguments);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PM_PUTNIL;
|
PUSH_INSN(ret, location, putnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_INSN1(ret, &dummy_line_node, throw, INT2FIX(throw_flag | TAG_BREAK));
|
PUSH_INSN1(ret, location, throw, INT2FIX(throw_flag | TAG_BREAK));
|
||||||
PM_POP_IF_POPPED;
|
if (popped) PUSH_INSN(ret, location, pop);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
COMPILE_ERROR(ERROR_ARGS "Invalid break");
|
COMPILE_ERROR(ERROR_ARGS "Invalid break");
|
||||||
rb_bug("Invalid break");
|
rb_bug("Invalid break");
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче