Add flags: Type_Info_Flags, to runtime.Type_Info

This commit is contained in:
gingerBill
2020-11-23 14:35:31 +00:00
parent 9e42cb1595
commit 0b30c3dc5a
6 changed files with 52 additions and 6 deletions
+23
View File
@@ -373,7 +373,28 @@ enum Typeid_Kind : u8 {
Typeid_Relative_Slice,
};
// IMPORTANT NOTE(bill): This must match the same as the in core.odin
enum TypeInfoFlag : u32 {
TypeInfoFlag_Comparable = 1<<0,
TypeInfoFlag_Simple_Compare = 1<<1,
};
bool is_type_comparable(Type *t);
bool is_type_simple_compare(Type *t);
u32 type_info_flags_of_type(Type *type) {
if (type == nullptr) {
return 0;
}
u32 flags = 0;
if (is_type_comparable(type)) {
flags |= TypeInfoFlag_Comparable;
}
if (is_type_simple_compare(type)) {
flags |= TypeInfoFlag_Comparable;
}
return flags;
}
// TODO(bill): Should I add extra information here specifying the kind of selection?
@@ -1348,6 +1369,8 @@ bool is_type_simple_compare(Type *t) {
return false;
}
Type *base_complex_elem_type(Type *t) {
t = core_type(t);
if (t->kind == Type_Basic) {