aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'clox/src/object.c')
-rw-r--r--clox/src/object.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/clox/src/object.c b/clox/src/object.c
index 7e0dd6c..3732406 100644
--- a/clox/src/object.c
+++ b/clox/src/object.c
@@ -25,6 +25,13 @@ static Obj *allocateObject(size_t size, ObjType type) {
return object;
}
+ObjBoundMethod *newBoundMethod(Value receiver, ObjClosure *method) {
+ ObjBoundMethod *bound = ALLOCATE_OBJ(ObjBoundMethod, OBJ_BOUND_METHOD);
+ bound->receiver = receiver;
+ bound->method = method;
+ return bound;
+}
+
ObjClass *newClass(ObjString *name) {
ObjClass *klass = ALLOCATE_OBJ(ObjClass, OBJ_CLASS);
klass->name = name;
@@ -130,6 +137,9 @@ static void printFunction(ObjFunction *function) {
void printObject(Value value) {
switch (OBJ_TYPE(value)) {
+ case OBJ_BOUND_METHOD:
+ printFunction(AS_BOUND_METHOD(value)->method->function);
+ break;
case OBJ_CLASS:
printf("%s", AS_CLASS(value)->name->chars);
break;