}
static int
-compile_tree_empty_check(Node* node, regex_t* reg, int emptiness, ScanEnv* env)
+compile_tree_empty_check(QuantNode* qn, regex_t* reg, ScanEnv* env)
{
int r;
- int saved_num_null_check = reg->num_null_check;
+ int saved_num_null_check;
+ int emptiness;
+ Node* body;
+
+ body = NODE_BODY((Node* )qn);
+ emptiness = qn->emptiness;
+ saved_num_null_check = reg->num_null_check;
if (emptiness != BODY_IS_NOT_EMPTY) {
r = add_op(reg, OP_EMPTY_CHECK_START);
reg->num_null_check++;
}
- r = compile_tree(node, reg, env);
+ r = compile_tree(body, reg, env);
if (r != 0) return r;
if (emptiness != BODY_IS_NOT_EMPTY) {
if (emptiness == BODY_IS_EMPTY_POSSIBILITY)
r = add_op(reg, OP_EMPTY_CHECK_END);
- else if (emptiness == BODY_IS_EMPTY_POSSIBILITY_MEM)
- r = add_op(reg, OP_EMPTY_CHECK_END_MEMST);
+ else if (emptiness == BODY_IS_EMPTY_POSSIBILITY_MEM) {
+ if (NODE_IS_EMPTY_STATUS_CHECK(qn) != 0)
+ r = add_op(reg, OP_EMPTY_CHECK_END_MEMST);
+ else
+ r = add_op(reg, OP_EMPTY_CHECK_END);
+ }
else if (emptiness == BODY_IS_EMPTY_POSSIBILITY_REC)
r = add_op(reg, OP_EMPTY_CHECK_END_MEMST_PUSH);
r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper);
if (r != 0) return r;
- r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, emptiness, env);
+ r = compile_tree_empty_check(qn, reg, env);
if (r != 0) return r;
if (
COP(reg)->push_or_jump_exact1.addr = SIZE_INC + mod_tlen + OPSIZE_JUMP;
COP(reg)->push_or_jump_exact1.c = STR_(qn->head_exact)->s[0];
- r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, emptiness, env);
+ r = compile_tree_empty_check(qn, reg, env);
if (r != 0) return r;
addr = -(mod_tlen + (int )OPSIZE_PUSH_OR_JUMP_EXACT1);
COP(reg)->push_if_peek_next.addr = SIZE_INC + mod_tlen + OPSIZE_JUMP;
COP(reg)->push_if_peek_next.c = STR_(qn->next_head_exact)->s[0];
- r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, emptiness, env);
+ r = compile_tree_empty_check(qn, reg, env);
if (r != 0) return r;
addr = -(mod_tlen + (int )OPSIZE_PUSH_IF_PEEK_NEXT);
if (r != 0) return r;
COP(reg)->push.addr = SIZE_INC + mod_tlen + OPSIZE_JUMP;
- r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, emptiness, env);
+ r = compile_tree_empty_check(qn, reg, env);
if (r != 0) return r;
addr = -(mod_tlen + (int )OPSIZE_PUSH);
if (r != 0) return r;
COP(reg)->jump.addr = mod_tlen + SIZE_INC;
- r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, emptiness, env);
+ r = compile_tree_empty_check(qn, reg, env);
if (r != 0) return r;
r = add_op(reg, OP_PUSH);