diff --git a/lang/bytecode.c b/lang/bytecode.c index 45ca1e6..f7054bf 100644 --- a/lang/bytecode.c +++ b/lang/bytecode.c @@ -54,7 +54,7 @@ const char *dispatch = (const char *)pos_code; struct object *obj = *(--pos_stack); struct object **args = pos_stack - 2; - dispatch_call(obj, dispatch, 1, args); + dispatch_call(obj, dispatch, 2, args); break; } case OP_NULL: { diff --git a/lang/func.c b/lang/func.c index 5d41a56..b331fa7 100644 --- a/lang/func.c +++ b/lang/func.c @@ -28,7 +28,7 @@ } static void func_call(struct object *obj, int arg_count, struct object **args) { - abort_if(arg_count != 0, "func_add called with more than 0 arguments"); + abort_if(arg_count != 1, "func_add called with more than 1 argument"); abort_if(obj->class_data != &func_class, "func_call obj is not a func"); bytecode_run(args); } diff --git a/lang/main.c b/lang/main.c index 595715d..1fa6b33 100644 --- a/lang/main.c +++ b/lang/main.c @@ -9,7 +9,7 @@ struct object *numA = number_create(5); struct object *numB = number_create(3); struct object *args[] = {NULL, numB}; - dispatch_call(numA, "Add", 1, &args[0]); + dispatch_call(numA, "Add", 2, &args[0]); struct object *numC = args[0]; printf("numC value is %i\n", number_value(numC)); printf("numA is %p\n", (void *)numA); @@ -27,7 +27,7 @@ struct object *funcA = func_create(); // args must have space for a stack struct object *args[8] = {NULL}; - dispatch_call(funcA, "Call", 0, &args[0]); + dispatch_call(funcA, "Call", 1, &args[0]); printf("funcA is %p\n", (void *)funcA); object_drop(&funcA); printf("funcA is %p\n", (void *)funcA); diff --git a/lang/number.c b/lang/number.c index b5bfcec..ef76256 100644 --- a/lang/number.c +++ b/lang/number.c @@ -37,7 +37,8 @@ static void number_add( struct object *obj, int arg_count, struct object **args) { - abort_if(arg_count != 1, "number_add called with more than 1 argument"); + abort_if( + arg_count != 2, "number_add called with more than 2 arguments"); abort_if(args[0] != NULL, "number_add return is not NULL"); abort_if(!args[1], "number_add arg is NULL"); abort_if(obj->class_data != &num_class,