summaryrefslogtreecommitdiff
path: root/val.h
diff options
context:
space:
mode:
Diffstat (limited to 'val.h')
-rw-r--r--val.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/val.h b/val.h
index 4560a1c..1f2bd8d 100644
--- a/val.h
+++ b/val.h
@@ -10,9 +10,9 @@ typedef struct _obj Obj;
typedef enum {
+ TY_NIL,
TY_NUM,
TY_BOOL,
- TY_NIL,
} ValTy;
struct _val {
@@ -29,11 +29,18 @@ struct _obj {
int foo;
};
+void print_val(Val v);
+
#define IS_NUM(x) (x.ty == TY_NUM)
#define IS_BOOL(x) (x.ty == TY_BOOL)
#define IS_NIL(x) (x.ty == NIL)
+#define AS_NUM(x) (x.as.d)
+#define AS_BOOL(x) (x.as.b)
+#define VAL_NUM(x) ((Val){.ty=TY_NUM, .as.d=x})
+#define VAL_BOOL(x) ((Val){.ty=TY_BOOL, .as.b=x})
+#define VAL_NIL ((Val){.ty=TY_NIL})
#endif