From 95122a05146f3a9a7d4213907ae5dd9231e7990f Mon Sep 17 00:00:00 2001 From: Gavin Howard Date: Sat, 24 Jul 2021 14:46:33 -0600 Subject: Remove the loop for computed goto Signed-off-by: Gavin Howard --- src/program.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/program.c b/src/program.c index cc703bd7..72349052 100644 --- a/src/program.c +++ b/src/program.c @@ -2628,10 +2628,12 @@ void bc_program_exec(BcProgram *p) { #if BC_HAS_COMPUTED_GOTO BC_PROG_LBLS; -#endif // BC_HAS_COMPUTED_GOTO + // BC_INST_INVALID is a marker for the end so that we don't have to have an + // execution loop. func = (BcFunc*) bc_vec_item(&p->fns, BC_PROG_MAIN); bc_vec_pushByte(&func->code, BC_INST_INVALID); +#endif // BC_HAS_COMPUTED_GOTO ip = bc_vec_top(&p->stack); func = (BcFunc*) bc_vec_item(&p->fns, ip->func); @@ -2644,8 +2646,12 @@ void bc_program_exec(BcProgram *p) { // Ensure the pointers are correct. bc_program_setVecs(p, func); - // This loop is the heart of the execution engine. It *is* the engine. - while (true) { +#if !BC_HAS_COMPUTED_GOTO + // This loop is the heart of the execution engine. It *is* the engine. For + // computed goto, it is ignored. + while (true) +#endif // !BC_HAS_COMPUTED_GOTO + { BC_SIG_ASSERT_NOT_LOCKED; -- cgit v1.2.3