diff --git a/lang/func.c b/lang/func.c index c39bb5c..5711f34 100644 --- a/lang/func.c +++ b/lang/func.c @@ -7,6 +7,17 @@ #include "vm.h" #include +// clang-format off +static const unsigned char bytecode[] = { +0x09, 0x01, 0x05, 0x05, 0x05, 0x01, 0x6a, 0x02, 0x00, 0x00, +0x07, 0x01, 0x05, 0x06, 0x01, 0x06, 0x01, 0x04, 0x02, 0x41, +0x64, 0x64, 0x00, 0x09, 0x05, 0x07, 0x02, 0x05, 0x01, 0x02, +0x00, 0x00, 0x00, 0x06, 0x02, 0x04, 0x02, 0x4d, 0x69, 0x6e, +0x75, 0x73, 0x00, 0x09, 0x05, 0x07, 0x03, 0x06, 0x03, 0x07, +0x00, 0x08, 0x03, 0x03, +}; +// clang-format on + static struct object_class func_class; Object func_create(void) { @@ -19,22 +30,12 @@ static void func_call(VmState state, Object obj, void *priv) { (void)obj; - (void)priv; - // clang-format off - static const unsigned char bytecode[] = { - 0x09, 0x01, 0x05, 0x05, 0x05, 0x01, 0x6a, 0x02, 0x00, 0x00, - 0x07, 0x01, 0x05, 0x06, 0x01, 0x06, 0x01, 0x04, 0x02, 0x41, - 0x64, 0x64, 0x00, 0x09, 0x05, 0x07, 0x02, 0x05, 0x01, 0x02, - 0x00, 0x00, 0x00, 0x06, 0x02, 0x04, 0x02, 0x4d, 0x69, 0x6e, - 0x75, 0x73, 0x00, 0x09, 0x05, 0x07, 0x03, 0x06, 0x03, 0x07, - 0x00, 0x08, 0x03, 0x03, - }; - // clang-format on - bytecode_run(state, bytecode); + bytecode_run(state, (const unsigned char *)priv); } static struct object_call calls[] = { - {.name = "Call", .handler = func_call}, {.name = NULL, /* end */}}; + {.name = "Call", .handler = func_call, .priv = (void *)bytecode}, + {.name = NULL, /* end */}}; static struct object_class func_class = { .cleanup = func_cleanup,