diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-12-23 08:57:48 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:37:00 +0200 |
commit | 902a81528b9d2edcf93226a2ca13da6fcc1839e5 (patch) | |
tree | ea868fae662aab61f1caa50b16a8b02fe1e6836b /src/program.c | |
parent | 111bd0c7cb4b446c4bfe192b1df82845de17c005 (diff) |
wip: function pointers and other stuff
Diffstat (limited to 'src/program.c')
-rw-r--r-- | src/program.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/program.c b/src/program.c index 6c5ac7b..31485ca 100644 --- a/src/program.c +++ b/src/program.c @@ -605,7 +605,7 @@ static CHECK_RESULT int amal_program_read_instructions(amal_program *self, amal_ self->return_value_index = 0; /* func_offset will only be non-zero when the function has been decoded (FUNC_START) */ - if(func_def.func_offset != 0) { + if(func_def.func_offset != ~(u32)0UL) { /* TODO: Instead of pushing num args, push the sum of sizeof the last num_args */ return_if_error(amal_exec_call(executor, func_def.func_offset, dst_reg)); } else { @@ -633,7 +633,12 @@ static CHECK_RESULT int amal_program_read_instructions(amal_program *self, amal_ break; } case AMAL_OP_CALLR: { - assert(bool_false && "TODO: Implement CALLR"); + AmalReg dst_reg; + AmalReg func_ptr_reg = self->data.data[self->read_index]; + assert(self->return_value_index == 1); + dst_reg = self->return_values_stack[0]; + self->return_value_index = 0; + return_if_error(amal_exec_callr(executor, func_ptr_reg, dst_reg)); self->read_index += 1; break; } |