From 902a81528b9d2edcf93226a2ca13da6fcc1839e5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 23 Dec 2019 08:57:48 +0100 Subject: wip: function pointers and other stuff --- src/program.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/program.c') 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; } -- cgit v1.2.3