roza/lib/type.c

38 lines
579 B
C
Raw Normal View History

2023-12-09 17:24:41 +00:00
#include "type.h"
RZ_ENUM_C(TypeKind, TYPE_KIND);
void type_init(type_t* type, TypeKind kind)
{
assert(type);
type->kind = kind;
}
void type_free(type_t* type)
{
assert(type);
}
int type_eq(type_t* type, type_t* rhs)
{
assert(type);
assert(rhs);
return type->kind == rhs->kind;
}
size_t type_str(type_t* type, char* buffer, size_t size)
{
assert(buffer);
2023-12-18 18:34:31 +00:00
if (type)
{
return snprintf(buffer, size, "%s",
TypeKindStr[type->kind] + strlen("TYPE_"));
}
else
{
return snprintf(buffer, size, "*unknown*");
}
}