bc: stop using p->exits when parsing if()
function old new delta zbc_parse_stmt_possibly_auto 2180 2138 -42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
7415633128
commit
6b5b46f817
@ -4110,7 +4110,6 @@ static BC_STATUS zbc_parse_if(BcParse *p)
|
|||||||
{
|
{
|
||||||
BcStatus s;
|
BcStatus s;
|
||||||
BcInstPtr ip;
|
BcInstPtr ip;
|
||||||
BcInstPtr *ipp;
|
|
||||||
size_t *label;
|
size_t *label;
|
||||||
|
|
||||||
dbg_lex_enter("%s:%d entered", __func__, __LINE__);
|
dbg_lex_enter("%s:%d entered", __func__, __LINE__);
|
||||||
@ -4132,8 +4131,6 @@ static BC_STATUS zbc_parse_if(BcParse *p)
|
|||||||
ip.idx = p->func->labels.len;
|
ip.idx = p->func->labels.len;
|
||||||
ip.func = ip.len = 0;
|
ip.func = ip.len = 0;
|
||||||
bc_parse_pushIndex(p, ip.idx);
|
bc_parse_pushIndex(p, ip.idx);
|
||||||
//TODO: can get rid of p->exits stack?
|
|
||||||
bc_vec_push(&p->exits, &ip);
|
|
||||||
bc_vec_push(&p->func->labels, &ip.idx);
|
bc_vec_push(&p->func->labels, &ip.idx);
|
||||||
|
|
||||||
s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if");
|
s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if");
|
||||||
@ -4147,32 +4144,27 @@ static BC_STATUS zbc_parse_if(BcParse *p)
|
|||||||
if (s) RETURN_STATUS(s);
|
if (s) RETURN_STATUS(s);
|
||||||
|
|
||||||
ip2.idx = p->func->labels.len;
|
ip2.idx = p->func->labels.len;
|
||||||
ip2.func = ip.len = 0;
|
ip2.func = ip2.len = 0;
|
||||||
|
|
||||||
dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx);
|
dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx);
|
||||||
bc_parse_push(p, BC_INST_JUMP);
|
bc_parse_push(p, BC_INST_JUMP);
|
||||||
bc_parse_pushIndex(p, ip2.idx);
|
bc_parse_pushIndex(p, ip2.idx);
|
||||||
|
|
||||||
ipp = bc_vec_top(&p->exits);
|
label = bc_vec_item(&p->func->labels, ip.idx);
|
||||||
label = bc_vec_item(&p->func->labels, ipp->idx);
|
|
||||||
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
|
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
|
||||||
*label = p->func->code.len;
|
*label = p->func->code.len;
|
||||||
bc_vec_pop(&p->exits);
|
|
||||||
|
|
||||||
bc_vec_push(&p->exits, &ip2);
|
|
||||||
bc_vec_push(&p->func->labels, &ip2.idx);
|
bc_vec_push(&p->func->labels, &ip2.idx);
|
||||||
|
ip.idx = ip2.idx;
|
||||||
|
|
||||||
s = zbc_parse_stmt(p);
|
s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "else");
|
||||||
if (s) RETURN_STATUS(s);
|
if (s) RETURN_STATUS(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipp = bc_vec_top(&p->exits);
|
label = bc_vec_item(&p->func->labels, ip.idx);
|
||||||
label = bc_vec_item(&p->func->labels, ipp->idx);
|
|
||||||
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
|
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
|
||||||
*label = p->func->code.len;
|
*label = p->func->code.len;
|
||||||
|
|
||||||
bc_vec_pop(&p->exits);
|
|
||||||
|
|
||||||
dbg_lex_done("%s:%d done", __func__, __LINE__);
|
dbg_lex_done("%s:%d done", __func__, __LINE__);
|
||||||
RETURN_STATUS(s);
|
RETURN_STATUS(s);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user