diff options
Diffstat (limited to 'val.h')
-rw-r--r-- | val.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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 |