new built-in keysof and rewrote the json parser

This commit is contained in:
cozis
2022-12-06 22:43:13 +01:00
parent 7e3eb6364a
commit 380b8a8917
11 changed files with 521 additions and 219 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 *self, FILE *fp);
static bool istypeof(Object *self, Object *other, Heap *heap, Error *error);
typedef struct {
@@ -18,7 +19,7 @@ static TypeObject t_sum = {
.hash = NULL,
.copy = NULL,
.call = NULL,
.print = NULL,
.print = print,
.select = NULL,
.delete = NULL,
@@ -64,3 +65,11 @@ static void walk(Object *self, void (*callback)(Object **referer, void *userp),
callback(sum->items + 0, userp);
callback(sum->items + 1, userp);
}
static void print(Object *self, FILE *fp)
{
SumObject *sum = (SumObject*) self;
Object_Print(sum->items[0], fp);
fprintf(fp, " | ");
Object_Print(sum->items[1], fp);
}