lang: Add arg count to OP_CALL

This commit is contained in:
Jookia 2023-05-31 14:09:14 +10:00
parent b0921ec29c
commit 15e46a0876

View file

@ -25,7 +25,7 @@ static const unsigned char bytecode[] = {
OP_NULL,
OP_GET, 0x4,
OP_GET, 0x4,
OP_CALL, 'A', 'd', 'd', '\0',
OP_CALL, 0x2, 'A', 'd', 'd', '\0',
OP_DROP, 0x1,
OP_SET, 0x0,
OP_RET
@ -51,10 +51,11 @@ void bytecode_run(struct object **stack, int arg_count) {
break;
}
case OP_CALL: {
int arg_count = *pos_code++;
const char *dispatch = (const char *)pos_code;
struct object *obj = *(--pos_stack);
struct object **args = pos_stack - 2;
dispatch_call(obj, dispatch, 2, args);
struct object **args = pos_stack - arg_count;
dispatch_call(obj, dispatch, arg_count, args);
break;
}
case OP_NULL: {