add nilptrs, more conversion functions and change how ptrs work

Pointers now no longer point to the Value struct (the internal wrapper for
values) but to the value itself.
This commit is contained in:
r4
2021-12-28 17:53:27 +01:00
parent befce544e7
commit ba8d2f0702
5 changed files with 51 additions and 10 deletions

View File

@@ -130,9 +130,12 @@ Value eval_unary(IRInstr instr, const Value *v) {
bool is_nonzero(const Value *v) {
switch (v->type) {
case TypeInt: return v->Int != 0;
case TypeFloat: return v->Float != 0.0;
case TypeInt: return v->Int != 0;
case TypeFloat: return v->Float != 0.0;
case TypeBool: return v->Bool;
case TypeChar: return v->Char != 0;
case TypePtr: return v->Ptr.val != NULL;
case TypeArr: return v->Arr.len != 0;
default: ASSERT_UNREACHED();
}
}