@@ -200,6 +200,8 @@ static InterpretResult run(VM* vm) {
200200#ifdef __GNUC__
201201 #define DISPATCH () goto *dispatch_table[*frame->ip++]
202202
203+ #pragma GCC diagnostic push
204+ #pragma GCC diagnostic ignored "-Woverride-init"
203205 static void * dispatch_table [256 ] = {
204206 [0 ... 255 ] = & & DO_OP_UNKNOWN ,
205207 [OP_CONSTANT ] = & & DO_OP_CONSTANT ,
@@ -251,6 +253,7 @@ static InterpretResult run(VM* vm) {
251253 [OP_END_TRY ] = & & DO_OP_END_TRY ,
252254 [OP_MAKE_FOREIGN ] = & & DO_OP_MAKE_FOREIGN
253255 };
256+ #pragma GCC diagnostic pop
254257
255258 DISPATCH ();
256259
@@ -606,7 +609,6 @@ static InterpretResult run(VM* vm) {
606609 } else if (IS_CLASS (callee )) {
607610 ObjClass * klass = AS_CLASS (callee );
608611 vm -> stackTop [- argCount - 1 ] = OBJ_VAL (newInstance (klass ));
609- Value initializer ;
610612 // Check for 'init' method
611613 // If init exists, call it.
612614 // Note: we can't easily string check without an ObjString for "init".
@@ -634,8 +636,25 @@ static InterpretResult run(VM* vm) {
634636 }
635637 DISPATCH ();
636638 }
637- DO_OP_INVOKE :
638- DO_OP_SUPER_INVOKE :
639+ DO_OP_INVOKE : {
640+ ObjString * method = READ_STRING ();
641+ int argCount = READ_BYTE ();
642+ if (!invoke (method , argCount , vm )) {
643+ return INTERPRET_RUNTIME_ERROR ;
644+ }
645+ frame = & vm -> frames [vm -> frameCount - 1 ];
646+ DISPATCH ();
647+ }
648+ DO_OP_SUPER_INVOKE : {
649+ ObjString * method = READ_STRING ();
650+ int argCount = READ_BYTE ();
651+ ObjClass * superclass = AS_CLASS (pop (vm ));
652+ if (!invokeFromClass (superclass , method , argCount , vm )) {
653+ return INTERPRET_RUNTIME_ERROR ;
654+ }
655+ frame = & vm -> frames [vm -> frameCount - 1 ];
656+ DISPATCH ();
657+ }
639658 DO_OP_CLOSURE : {
640659 ObjFunction * function = AS_FUNCTION (READ_CONSTANT ());
641660 ObjClosure * closure = newClosure (function );
0 commit comments