Inherit methods from enclosing classes.

Like NewtonScript, the inner classes superclasses take precedence, but
if not found there then the enclosing classes are searched.

This code is still a bit hacky in some corners, but it's a step in the
right direction.
This commit is contained in:
Bob Nystrom
2015-12-21 17:05:46 -08:00
parent 8ff11a3c2c
commit c472a61bff
5 changed files with 103 additions and 10 deletions

View File

@ -375,6 +375,8 @@ struct sObjClass
{
Obj obj;
ObjClass* superclass;
ObjClass* enclosingClass;
// The number of fields needed for an instance of this class, including all
// of its superclass fields.
@ -615,7 +617,8 @@ ObjClass* wrenNewSingleClass(WrenVM* vm, int numFields, ObjString* name);
void wrenBindSuperclass(WrenVM* vm, ObjClass* subclass, ObjClass* superclass);
// Creates a new class object as well as its associated metaclass.
ObjClass* wrenNewClass(WrenVM* vm, ObjClass* superclass, int numFields,
ObjClass* wrenNewClass(WrenVM* vm, ObjClass* superclass,
ObjClass* enclosingClass, int numFields,
ObjString* name);
void wrenBindMethod(WrenVM* vm, ObjClass* classObj, int symbol, Method method);