diff options
Diffstat (limited to 'val.c')
-rw-r--r-- | val.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -81,6 +81,17 @@ bool is_truthy(Val v) { return true; } +bool val_equal(Val a, Val b) { + if (a.ty != b.ty) return false; + switch (a.ty) { + case TY_NIL: return true; + case TY_NUM: return AS_NUM(a) == AS_NUM(b); + case TY_BOOL: return AS_BOOL(a) == AS_BOOL(b); + case TY_OBJ: return AS_OBJ(a) == AS_OBJ(b); + default: return false; + } +} + const char *typename_str(Val v) { switch(v.ty) { |