summaryrefslogtreecommitdiff
path: root/val.c
diff options
context:
space:
mode:
Diffstat (limited to 'val.c')
-rw-r--r--val.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/val.c b/val.c
index 4456148..9e832a6 100644
--- a/val.c
+++ b/val.c
@@ -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];
+}