aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:04:44 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:05:09 +0100
commit3f8544485affaf2e701992cdfaedac13e86e050a (patch)
treed50b55d178f382f0a8c21000e07f9818f3c017e5
parent56c545e7c9b9074a5c5e621b57c87e9e6556978b (diff)
downloadovm-3f8544485affaf2e701992cdfaedac13e86e050a.tar.gz
ovm-3f8544485affaf2e701992cdfaedac13e86e050a.tar.bz2
ovm-3f8544485affaf2e701992cdfaedac13e86e050a.zip
Move push routines outside of vm_execute
-rw-r--r--src/main.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 301a468..c6d842e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -147,6 +147,14 @@ f64 vm_pop_float(vm_t *vm)
return f;
}
+typedef void (*push_f)(vm_t *, data_t);
+
+static const push_f PUSH_ROUTINES[] = {
+ [OP_PUSH_BYTE] = vm_push_byte,
+ [OP_PUSH_WORD] = vm_push_word,
+ [OP_PUSH_FLOAT] = vm_push_float,
+};
+
void vm_execute(vm_t *vm)
{
struct Program *prog = &vm->program;
@@ -158,11 +166,7 @@ void vm_execute(vm_t *vm)
// Check if opcode is PUSH_LIKE
if (OPCODE_IS_PUSH(instruction.opcode))
{
- typedef void (*push_f)(vm_t *, data_t);
- const push_f routines[] = {[OP_PUSH_BYTE] = vm_push_byte,
- [OP_PUSH_WORD] = vm_push_word,
- [OP_PUSH_FLOAT] = vm_push_float};
- routines[instruction.opcode](vm, instruction.operand);
+ PUSH_ROUTINES[instruction.opcode](vm, instruction.operand);
prog->ptr++;
}
else