added print object method

This commit is contained in:
cozis
2021-11-01 16:12:08 +00:00
parent 5bf6a9f085
commit d93f578eb2
7 changed files with 85 additions and 2 deletions
+18
View File
@@ -106,6 +106,24 @@ Object *Object_Call(Object *obj, Object **argv, unsigned int argc, Heap *heap, E
return type->call(obj, argv, argc, heap, err);
}
_Bool Object_Print(Object *obj, FILE *fp, Error *error)
{
assert(error != NULL);
assert(obj != NULL);
const Type *type = Object_GetType(obj);
assert(type);
if(type->print == NULL)
{
Error_Report(error, 0, "Object %s doesn't implement %s", Object_GetName(obj), __func__);
return 0;
}
type->print(obj, fp);
return 1;
}
Object *Object_Select(Object *coll, Object *key, Heap *heap, Error *err)
{
assert(err);