add pointers, variable arguments and void functions

This commit is contained in:
r4
2021-12-28 13:39:12 +01:00
parent a706ea6a3f
commit 22f71d7e56
9 changed files with 140 additions and 40 deletions

8
tok.c
View File

@@ -20,6 +20,7 @@ const char *type_str[TypeEnumSize] = {
[TypeInt] = "int",
[TypeBool] = "bool",
[TypeChar] = "char",
[TypePtr] = "ptr",
[TypeArr] = "arr",
};
@@ -46,6 +47,11 @@ void print_value(const Value *v, bool raw) {
else printf("'%c'", v->Char);
}
break;
case TypePtr:
printf("ptr<%s>(", type_str[v->Ptr.type.kind]);
print_value(v->Ptr.val, false);
printf(")");
break;
case TypeArr:
if (v->Arr.is_string) {
if (v->Arr.type.kind != TypeChar)
@@ -72,7 +78,7 @@ void print_value(const Value *v, bool raw) {
Value ty_val = { .type = v->Arr.type };
memcpy(&ty_val.Void, (uint8_t*)v->Arr.vals + ty_sz * i, ty_sz);
print_value(&ty_val, false);
if (i == v->Arr.len-1) break;
if (i+1 >= v->Arr.len) break;
printf(", ");
}
printf("]");