[PRISM] Remove more dummy line usage
* regular expressions * rescue * rescue modifier
This commit is contained in:
parent
e7d480df5d
commit
e1f6b477e0
@ -6677,23 +6677,24 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PM_REGULAR_EXPRESSION_NODE: {
|
case PM_REGULAR_EXPRESSION_NODE: {
|
||||||
|
// /foo/
|
||||||
|
// ^^^^^
|
||||||
if (!popped) {
|
if (!popped) {
|
||||||
pm_regular_expression_node_t *cast = (pm_regular_expression_node_t *) node;
|
VALUE regex = pm_static_literal_value(node, scope_node);
|
||||||
|
PUSH_INSN1(ret, location, putobject, regex);
|
||||||
VALUE regex = pm_new_regex(cast, parser);
|
|
||||||
|
|
||||||
ADD_INSN1(ret, &dummy_line_node, putobject, regex);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PM_RESCUE_NODE: {
|
case PM_RESCUE_NODE: {
|
||||||
pm_rescue_node_t *cast = (pm_rescue_node_t *) node;
|
// begin; rescue; end
|
||||||
|
// ^^^^^^^
|
||||||
|
const pm_rescue_node_t *cast = (const pm_rescue_node_t *) node;
|
||||||
iseq_set_exception_local_table(iseq);
|
iseq_set_exception_local_table(iseq);
|
||||||
|
|
||||||
// First, establish the labels that we need to be able to jump to within
|
// First, establish the labels that we need to be able to jump to within
|
||||||
// this compilation block.
|
// this compilation block.
|
||||||
LABEL *exception_match_label = NEW_LABEL(lineno);
|
LABEL *exception_match_label = NEW_LABEL(location.line);
|
||||||
LABEL *rescue_end_label = NEW_LABEL(lineno);
|
LABEL *rescue_end_label = NEW_LABEL(location.line);
|
||||||
|
|
||||||
// Next, compile each of the exceptions that we're going to be
|
// Next, compile each of the exceptions that we're going to be
|
||||||
// handling. For each one, we'll add instructions to check if the
|
// handling. For each one, we'll add instructions to check if the
|
||||||
@ -6701,7 +6702,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// exception_match_label label. Otherwise it will fall through to the
|
// exception_match_label label. Otherwise it will fall through to the
|
||||||
// subsequent check. If there are no exceptions, we'll only check
|
// subsequent check. If there are no exceptions, we'll only check
|
||||||
// StandardError.
|
// StandardError.
|
||||||
pm_node_list_t *exceptions = &cast->exceptions;
|
const pm_node_list_t *exceptions = &cast->exceptions;
|
||||||
|
|
||||||
if (exceptions->size > 0) {
|
if (exceptions->size > 0) {
|
||||||
for (size_t index = 0; index < exceptions->size; index++) {
|
for (size_t index = 0; index < exceptions->size; index++) {
|
||||||
@ -6711,25 +6712,25 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
if (PM_NODE_TYPE_P(exceptions->nodes[index], PM_SPLAT_NODE)) {
|
if (PM_NODE_TYPE_P(exceptions->nodes[index], PM_SPLAT_NODE)) {
|
||||||
checkmatch_flags |= VM_CHECKMATCH_ARRAY;
|
checkmatch_flags |= VM_CHECKMATCH_ARRAY;
|
||||||
}
|
}
|
||||||
ADD_INSN1(ret, &dummy_line_node, checkmatch, INT2FIX(checkmatch_flags));
|
PUSH_INSN1(ret, location, checkmatch, INT2FIX(checkmatch_flags));
|
||||||
ADD_INSNL(ret, &dummy_line_node, branchif, exception_match_label);
|
PUSH_INSNL(ret, location, branchif, exception_match_label);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ADD_GETLOCAL(ret, &dummy_line_node, LVAR_ERRINFO, 0);
|
ADD_GETLOCAL(ret, &dummy_line_node, LVAR_ERRINFO, 0);
|
||||||
ADD_INSN1(ret, &dummy_line_node, putobject, rb_eStandardError);
|
PUSH_INSN1(ret, location, putobject, rb_eStandardError);
|
||||||
ADD_INSN1(ret, &dummy_line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
|
PUSH_INSN1(ret, location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
|
||||||
ADD_INSNL(ret, &dummy_line_node, branchif, exception_match_label);
|
PUSH_INSNL(ret, location, branchif, exception_match_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none of the exceptions that we are matching against matched, then
|
// If none of the exceptions that we are matching against matched, then
|
||||||
// we'll jump straight to the rescue_end_label label.
|
// we'll jump straight to the rescue_end_label label.
|
||||||
ADD_INSNL(ret, &dummy_line_node, jump, rescue_end_label);
|
PUSH_INSNL(ret, location, jump, rescue_end_label);
|
||||||
|
|
||||||
// Here we have the exception_match_label, which is where the
|
// Here we have the exception_match_label, which is where the
|
||||||
// control-flow goes in the case that one of the exceptions matched.
|
// control-flow goes in the case that one of the exceptions matched.
|
||||||
// Here we will compile the instructions to handle the exception.
|
// Here we will compile the instructions to handle the exception.
|
||||||
ADD_LABEL(ret, exception_match_label);
|
PUSH_LABEL(ret, exception_match_label);
|
||||||
ADD_TRACE(ret, RUBY_EVENT_RESCUE);
|
PUSH_TRACE(ret, RUBY_EVENT_RESCUE);
|
||||||
|
|
||||||
// If we have a reference to the exception, then we'll compile the write
|
// If we have a reference to the exception, then we'll compile the write
|
||||||
// into the instruction sequence. This can look quite different
|
// into the instruction sequence. This can look quite different
|
||||||
@ -6763,16 +6764,16 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// Now restore the end_label
|
// Now restore the end_label
|
||||||
ISEQ_COMPILE_DATA(iseq)->end_label = prev_end;
|
ISEQ_COMPILE_DATA(iseq)->end_label = prev_end;
|
||||||
} else {
|
} else {
|
||||||
PM_PUTNIL;
|
PUSH_INSN(ret, location, putnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_INSN(ret, &dummy_line_node, leave);
|
PUSH_INSN(ret, location, leave);
|
||||||
|
|
||||||
// Here we'll insert the rescue_end_label label, which is jumped to if
|
// Here we'll insert the rescue_end_label label, which is jumped to if
|
||||||
// none of the exceptions matched. It will cause the control-flow to
|
// none of the exceptions matched. It will cause the control-flow to
|
||||||
// either jump to the next rescue clause or it will fall through to the
|
// either jump to the next rescue clause or it will fall through to the
|
||||||
// subsequent instruction returning the raised error.
|
// subsequent instruction returning the raised error.
|
||||||
ADD_LABEL(ret, rescue_end_label);
|
PUSH_LABEL(ret, rescue_end_label);
|
||||||
if (cast->consequent) {
|
if (cast->consequent) {
|
||||||
PM_COMPILE((pm_node_t *) cast->consequent);
|
PM_COMPILE((pm_node_t *) cast->consequent);
|
||||||
} else {
|
} else {
|
||||||
@ -6782,10 +6783,12 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PM_RESCUE_MODIFIER_NODE: {
|
case PM_RESCUE_MODIFIER_NODE: {
|
||||||
pm_rescue_modifier_node_t *cast = (pm_rescue_modifier_node_t *) node;
|
// foo rescue bar
|
||||||
|
// ^^^^^^^^^^^^^^
|
||||||
|
const pm_rescue_modifier_node_t *cast = (const pm_rescue_modifier_node_t *) node;
|
||||||
|
|
||||||
pm_scope_node_t rescue_scope_node;
|
pm_scope_node_t rescue_scope_node;
|
||||||
pm_scope_node_init((pm_node_t *) cast, &rescue_scope_node, scope_node, parser);
|
pm_scope_node_init((const pm_node_t *) cast, &rescue_scope_node, scope_node, parser);
|
||||||
|
|
||||||
rb_iseq_t *rescue_iseq = NEW_CHILD_ISEQ(
|
rb_iseq_t *rescue_iseq = NEW_CHILD_ISEQ(
|
||||||
&rescue_scope_node,
|
&rescue_scope_node,
|
||||||
@ -6796,19 +6799,18 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
|
|
||||||
pm_scope_node_destroy(&rescue_scope_node);
|
pm_scope_node_destroy(&rescue_scope_node);
|
||||||
|
|
||||||
LABEL *lstart = NEW_LABEL(lineno);
|
LABEL *lstart = NEW_LABEL(location.line);
|
||||||
LABEL *lend = NEW_LABEL(lineno);
|
LABEL *lend = NEW_LABEL(location.line);
|
||||||
LABEL *lcont = NEW_LABEL(lineno);
|
LABEL *lcont = NEW_LABEL(location.line);
|
||||||
|
|
||||||
lstart->rescued = LABEL_RESCUE_BEG;
|
lstart->rescued = LABEL_RESCUE_BEG;
|
||||||
lend->rescued = LABEL_RESCUE_END;
|
lend->rescued = LABEL_RESCUE_END;
|
||||||
ADD_LABEL(ret, lstart);
|
PUSH_LABEL(ret, lstart);
|
||||||
PM_COMPILE_NOT_POPPED(cast->expression);
|
PM_COMPILE_NOT_POPPED(cast->expression);
|
||||||
ADD_LABEL(ret, lend);
|
PUSH_LABEL(ret, lend);
|
||||||
PM_NOP;
|
PUSH_INSN(ret, location, nop);
|
||||||
ADD_LABEL(ret, lcont);
|
PUSH_LABEL(ret, lcont);
|
||||||
|
if (popped) PUSH_INSN(ret, location, pop);
|
||||||
PM_POP_IF_POPPED;
|
|
||||||
|
|
||||||
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue_iseq, lcont);
|
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue_iseq, lcont);
|
||||||
ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, NULL, lstart);
|
ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, NULL, lstart);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user