aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-07-24 14:46:33 -0600
committerGavin Howard <gavin@yzena.com>2021-07-24 14:46:33 -0600
commit95122a05146f3a9a7d4213907ae5dd9231e7990f (patch)
treeaa088bbf14c27dcdef9b9367e23a207f9fc14ec2 /src
parent2f637bd38af83854cdec0608dc2c8b07a21144ed (diff)
downloadplatform_external_bc-95122a05146f3a9a7d4213907ae5dd9231e7990f.tar.gz
platform_external_bc-95122a05146f3a9a7d4213907ae5dd9231e7990f.tar.bz2
platform_external_bc-95122a05146f3a9a7d4213907ae5dd9231e7990f.zip
Remove the loop for computed goto
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'src')
-rw-r--r--src/program.c12
1 files changed, 9 insertions, 3 deletions
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;