diff options
author | Denys Vlasenko | 2018-12-19 15:13:14 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-12-19 15:13:14 +0100 |
commit | 65e1046abf28a3b73e56e6b17ae936e7b2f314c3 (patch) | |
tree | 0a4a2e89b4d12830cfaf0bf7de89cd139d9b60d7 /miscutils | |
parent | 684d441f5c8c4eac5962ad0e0b59e8999284fe6a (diff) | |
download | busybox-65e1046abf28a3b73e56e6b17ae936e7b2f314c3.zip busybox-65e1046abf28a3b73e56e6b17ae936e7b2f314c3.tar.gz |
bc: open-code bc_parse_updateFunc() macro
This clearly shows one place which would need changing
for nested funcdefs to work.
function old new delta
bc_parse_reset 106 110 +4
zbc_vm_process 586 585 -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-1) Total: 3 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index d03d38a..8d2c270 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -1171,6 +1171,8 @@ static BcFunc* bc_program_func(size_t idx) { return bc_vec_item(&G.prog.fns, idx); } +// BC_PROG_MAIN is zeroth element, so: +#define bc_program_func_BC_PROG_MAIN() ((BcFunc*)(G.prog.fns.v)) static void *bc_vec_item_rev(const BcVec *v, size_t idx) { @@ -3538,9 +3540,6 @@ static void bc_program_reset(void) ip->idx = f->code.len; } -#define bc_parse_updateFunc(p, f) \ - ((p)->func = bc_program_func((p)->fidx = (f))) - // Called when zbc/zdc_parse_parse() detects a failure, // resets parsing structures. static void bc_parse_reset(BcParse *p) @@ -3551,7 +3550,8 @@ static void bc_parse_reset(BcParse *p) bc_vec_pop_all(&p->func->autos); bc_vec_pop_all(&p->func->labels); - bc_parse_updateFunc(p, BC_PROG_MAIN); + p->fidx = BC_PROG_MAIN; + p->func = bc_program_func_BC_PROG_MAIN(); } p->l.i = p->l.len; @@ -3581,7 +3581,8 @@ static void bc_parse_create(BcParse *p, size_t func) bc_vec_init(&p->conds, sizeof(size_t), NULL); bc_vec_init(&p->ops, sizeof(BcLexType), NULL); - bc_parse_updateFunc(p, func); + p->fidx = func; + p->func = bc_program_func(func); } #if ENABLE_BC @@ -4339,7 +4340,10 @@ static BC_STATUS zbc_parse_funcdef(BcParse *p) if (s) RETURN_STATUS(s); bc_parse_push(p, BC_INST_RET0); - bc_parse_updateFunc(p, BC_PROG_MAIN); + + // Subsequent code generation is into main program + p->fidx = BC_PROG_MAIN; + p->func = bc_program_func_BC_PROG_MAIN(); dbg_lex_done("%s:%d done", __func__, __LINE__); RETURN_STATUS(s); |