From ba0eb2042cefce45efa5c1ad294f05d0122815ee Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 22 Jun 2024 11:51:59 +0100 Subject: fix circular dependencies --- val.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'val.h') diff --git a/val.h b/val.h index 1db122b..e4227a4 100644 --- a/val.h +++ b/val.h @@ -5,10 +5,8 @@ #include #include - typedef struct _val Val; typedef struct _obj Obj; -typedef struct _state State; typedef enum { @@ -26,6 +24,8 @@ typedef struct _val { Obj *o; } as; } Val; + + void print_val(Val v); void println_val(Val v); const char *typename_str(Val v); @@ -36,6 +36,7 @@ bool val_equal(Val a, Val b); typedef enum { OTY_STRING, + OTY_FUNC, } ObjTy; typedef struct _obj { @@ -48,6 +49,12 @@ typedef struct { uint32_t hash; char *d; } ObjString; +#include "chunk.h" + +typedef struct { + Obj obj; + Chunk chunk; +} ObjFunc; // Constructs a new objstring from the given C string, // creating its own fresh copy of the data. @@ -57,6 +64,7 @@ ObjString *objstring_copy_cstr(State *s, char *str); // taking ownership of the provided data. ObjString *objstring_take(State *S, char *src, size_t len); +ObjFunc *objfunc_new(State *S); #define IS_NIL(x) (x.ty == TY_NIL) #define IS_NUM(x) (x.ty == TY_NUM) @@ -71,6 +79,7 @@ ObjString *objstring_take(State *S, char *src, size_t len); #define AS_STRING(x) ((ObjString*)AS_OBJ(x)) #define AS_CSTRING(x) (AS_STRING(x)->d) +#define AS_FUNC(x) ((ObjFunc*)AS_OBJ(x)) #define VAL_NIL ((Val){.ty=TY_NIL}) #define VAL_NUM(x) ((Val){.ty=TY_NUM, .as.d=(x) }) -- cgit v1.2.3