diff options
Diffstat (limited to 'val.c')
-rw-r--r-- | val.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -4,13 +4,28 @@ void print_val(Val v) { switch (v.ty) { case TY_NIL: - printf("nil\n"); + printf("nil"); break; case TY_NUM: - printf("%f\n",AS_NUM(v)); + printf("%f",AS_NUM(v)); break; case TY_BOOL: - printf("%s\n",AS_BOOL(v) ? "true" : "false"); + printf("%s",AS_BOOL(v) ? "true" : "false"); break; } } + +void println_val(Val v) { + print_val(v); + putchar('\n'); +} + +static const char *ty_names[] = { + "nil", + "num", + "bool", +}; + +const char *valty_str(ValTy ty) { + return ty_names[ty]; +} |