// SPDX-License-Identifier: MIT // Copyright (c) 2023 John Watts and the LuminaSensum contributors #include "func.h" #include "number.h" #include <stdio.h> static void test_number(void) { struct object *numA = number_create(5); struct object *numB = number_create(3); struct object *args[] = {NULL, numB}; 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); printf("numB is %p\n", (void *)numB); printf("numC is %p\n", (void *)numC); object_drop(&numA); object_drop(&numB); object_drop(&numC); printf("numA is %p\n", (void *)numA); printf("numB is %p\n", (void *)numB); printf("numC is %p\n", (void *)numC); } static void test_func(void) { struct object *funcA = func_create(); // args must have space for a stack struct object *args[8] = {NULL}; dispatch_call(funcA, "Call", 1, &args[0]); printf("funcA is %p\n", (void *)funcA); object_drop(&funcA); printf("funcA is %p\n", (void *)funcA); struct object *numA = args[0]; printf("numA is %p\n", (void *)numA); printf("code return value is %i\n", number_value(numA)); object_drop(&numA); printf("numA is %p\n", (void *)numA); } int lang_main(void) { printf("Hello world!\n"); test_number(); test_func(); return 0; }