added "any" type

This commit is contained in:
cozis
2022-12-05 17:02:13 +01:00
parent ea428fdca2
commit 8f2723c3aa
15 changed files with 172 additions and 149 deletions
+10 -1
View File
@@ -2,6 +2,7 @@
#include "objects.h"
static void walk(Object *self, void (*callback)(Object **referer, void *userp), void *userp);
static void print(Object *obj, FILE *fp);
static bool istypeof(Object *self, Object *other, Heap *heap, Error *error);
typedef struct {
@@ -18,7 +19,7 @@ static TypeObject t_nullable = {
.hash = NULL,
.copy = NULL,
.call = NULL,
.print = NULL,
.print = print,
.select = NULL,
.delete = NULL,
@@ -62,3 +63,11 @@ static void walk(Object *self, void (*callback)(Object **referer, void *userp),
NullableObject *nullable = (NullableObject*) self;
callback(&nullable->item, userp);
}
static void print(Object *obj, FILE *fp)
{
NullableObject *nullable = (NullableObject*) obj;
fprintf(fp, "?");
Object_Print(nullable->item, fp);
}