summaryrefslogtreecommitdiff
path: root/val.h
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-20 16:00:34 +0100
committerubq323 <ubq323@ubq323.website>2024-06-20 16:00:34 +0100
commit60b3369ab24f9bd2a4a6d638ab1b3013ebc29814 (patch)
tree3ff8ec7e95ef314266673b1b3d7bedb880a4a5b0 /val.h
parent9ee73a8459eb2bb58adc29da02de312b7e4e7dca (diff)
pass State *S everywhere
contains changes from a million years ago that i don't remember much about
Diffstat (limited to 'val.h')
-rw-r--r--val.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/val.h b/val.h
index 3cf3251..d742c14 100644
--- a/val.h
+++ b/val.h
@@ -8,6 +8,7 @@
typedef struct _val Val;
typedef struct _obj Obj;
+typedef struct _state State;
typedef enum {
@@ -42,11 +43,15 @@ typedef struct {
Obj obj;
size_t len;
uint32_t hash;
- char *b;
+ char *d;
} ObjString;
-ObjString *objstring_copy(char *src, size_t len);
-ObjString *objstring_take(char *src, size_t len);
+// Constructs a new objstring from the given C string,
+// creating its own fresh copy of the data.
+ObjString *objstring_copy(State *S, char *src, size_t len);
+// Constructs a new objstring from the given C string,
+// taking ownership of the provided data.
+ObjString *objstring_take(State *S, char *src, size_t len);
#define IS_NIL(x) (x.ty == NIL)
@@ -61,7 +66,7 @@ ObjString *objstring_take(char *src, size_t len);
#define AS_OBJ(x) (x.as.o)
#define AS_STRING(x) ((ObjString*)AS_OBJ(x))
-#define AS_CSTRING(x) (AS_STRING(x)->b)
+#define AS_CSTRING(x) (AS_STRING(x)->d)
#define VAL_NIL ((Val){.ty=TY_NIL})
#define VAL_NUM(x) ((Val){.ty=TY_NUM, .as.d=(x) })