Reorder the method types.
Seems to slightly improve perf.
This commit is contained in:
parent
4ba5c38bbf
commit
8e71660ce6
@ -156,9 +156,6 @@ typedef struct
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
// No method for the given symbol.
|
|
||||||
METHOD_NONE,
|
|
||||||
|
|
||||||
// A primitive method implemented in C that immediately returns a value.
|
// A primitive method implemented in C that immediately returns a value.
|
||||||
METHOD_PRIMITIVE,
|
METHOD_PRIMITIVE,
|
||||||
|
|
||||||
@ -171,7 +168,10 @@ typedef enum
|
|||||||
// A constructor. This will be defined on the metaclass. If [fn] is non-NULL,
|
// A constructor. This will be defined on the metaclass. If [fn] is non-NULL,
|
||||||
// then it's a user-defined constructor and [fn] is the initialization code.
|
// then it's a user-defined constructor and [fn] is the initialization code.
|
||||||
// Otherwise, it's a default constructor.
|
// Otherwise, it's a default constructor.
|
||||||
METHOD_CTOR
|
METHOD_CTOR,
|
||||||
|
|
||||||
|
// No method for the given symbol.
|
||||||
|
METHOD_NONE
|
||||||
} MethodType;
|
} MethodType;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@ -673,15 +673,6 @@ Value interpret(WrenVM* vm, Value function)
|
|||||||
Method* method = &classObj->methods[symbol];
|
Method* method = &classObj->methods[symbol];
|
||||||
switch (method->type)
|
switch (method->type)
|
||||||
{
|
{
|
||||||
case METHOD_NONE:
|
|
||||||
printf("Receiver ");
|
|
||||||
wrenPrintValue(receiver);
|
|
||||||
printf(" does not implement method \"%s\".\n",
|
|
||||||
vm->methods.names[symbol]);
|
|
||||||
// TODO(bob): Throw an exception or halt the fiber or something.
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case METHOD_PRIMITIVE:
|
case METHOD_PRIMITIVE:
|
||||||
{
|
{
|
||||||
Value* args = &fiber->stack[fiber->stackSize - numArgs];
|
Value* args = &fiber->stack[fiber->stackSize - numArgs];
|
||||||
@ -724,6 +715,15 @@ Value interpret(WrenVM* vm, Value function)
|
|||||||
LOAD_FRAME();
|
LOAD_FRAME();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case METHOD_NONE:
|
||||||
|
printf("Receiver ");
|
||||||
|
wrenPrintValue(receiver);
|
||||||
|
printf(" does not implement method \"%s\".\n",
|
||||||
|
vm->methods.names[symbol]);
|
||||||
|
// TODO(bob): Throw an exception or halt the fiber or something.
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user