implemented nullable type notation
This commit is contained in:
@@ -33,14 +33,21 @@
|
||||
#include "../common/defs.h"
|
||||
|
||||
static _Bool op_eql(Object *self, Object *other);
|
||||
static bool istypeof(Object *self, Object *other);
|
||||
|
||||
TypeObject t_type = {
|
||||
.base = (Object) { .type = &t_type, .flags = Object_STATIC },
|
||||
.name = TYPENAME_TYPE,
|
||||
.size = sizeof(TypeObject),
|
||||
.istypeof = istypeof,
|
||||
.op_eql = op_eql,
|
||||
};
|
||||
|
||||
static bool istypeof(Object *self, Object *other)
|
||||
{
|
||||
return other->type == (TypeObject*) self;
|
||||
}
|
||||
|
||||
TypeObject *Object_GetTypeType()
|
||||
{
|
||||
return &t_type;
|
||||
@@ -71,6 +78,13 @@ const TypeObject *Object_GetType(const Object *obj)
|
||||
return obj->type;
|
||||
}
|
||||
|
||||
bool Object_IsTypeOf(Object *typ, Object *obj)
|
||||
{
|
||||
if (typ->type->istypeof == NULL)
|
||||
return false;
|
||||
return typ->type->istypeof(typ, obj);
|
||||
}
|
||||
|
||||
int Object_Hash(Object *obj)
|
||||
{
|
||||
ASSERT(obj != NULL);
|
||||
|
||||
Reference in New Issue
Block a user