aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorUsername-Leon <leonardo.temperanza@gmail.com>2025-10-15 15:30:32 +0200
committerUsername-Leon <leonardo.temperanza@gmail.com>2025-10-15 15:30:32 +0200
commit4dd6bb2e871e9b8583a89e62ce36a98d02d48cc3 (patch)
tree25b7599645caf76ebe9136da51e5114006ab93f4 /src/types.cpp
parente10093bd991334789031df9ed587d27823ca90dd (diff)
parent596066aa0453752f24cc2fa5087fafe2c4686536 (diff)
Merge branch 'master' of https://github.com/LeonardoTemperanza/Odin
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/types.cpp b/src/types.cpp
index effa8ef64..cb830d08d 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -410,7 +410,7 @@ gb_internal u32 type_info_flags_of_type(Type *type) {
flags |= TypeInfoFlag_Comparable;
}
if (is_type_simple_compare(type)) {
- flags |= TypeInfoFlag_Comparable;
+ flags |= TypeInfoFlag_Comparable|TypeInfoFlag_Simple_Compare;
}
return flags;
}
@@ -752,11 +752,14 @@ gb_global Type *t_objc_object = nullptr;
gb_global Type *t_objc_selector = nullptr;
gb_global Type *t_objc_class = nullptr;
gb_global Type *t_objc_ivar = nullptr;
+gb_global Type *t_objc_super = nullptr; // Struct used in lieu of the 'self' instance when calling objc_msgSendSuper.
+gb_global Type *t_objc_super_ptr = nullptr;
gb_global Type *t_objc_id = nullptr;
gb_global Type *t_objc_SEL = nullptr;
gb_global Type *t_objc_Class = nullptr;
gb_global Type *t_objc_Ivar = nullptr;
+gb_global Type *t_objc_instancetype = nullptr; // Special distinct variant of t_objc_id used mimic auto-typing of instancetype* in Objective-C
enum OdinAtomicMemoryOrder : i32 {
OdinAtomicMemoryOrder_relaxed = 0, // unordered
@@ -1722,7 +1725,7 @@ gb_internal bool is_type_u8_ptr(Type *t) {
t = base_type(t);
if (t == nullptr) { return false; }
if (t->kind == Type_Pointer) {
- return is_type_u8(t->Slice.elem);
+ return is_type_u8(t->Pointer.elem);
}
return false;
}
@@ -1763,7 +1766,7 @@ gb_internal bool is_type_u16_ptr(Type *t) {
t = base_type(t);
if (t == nullptr) { return false; }
if (t->kind == Type_Pointer) {
- return is_type_u16(t->Slice.elem);
+ return is_type_u16(t->Pointer.elem);
}
return false;
}
@@ -4735,6 +4738,14 @@ gb_internal bool is_type_objc_object(Type *t) {
return internal_check_is_assignable_to(t, t_objc_object);
}
+gb_internal bool is_type_objc_ptr_to_object(Type *t) {
+ // NOTE (harold): is_type_objc_object() returns true if it's a pointer to an object or the object itself.
+ // This returns true ONLY if Type is a shallow pointer to an Objective-C object.
+
+ Type *elem = type_deref(t);
+ return elem != t && elem->kind == Type_Named && is_type_objc_object(elem);
+}
+
gb_internal Type *get_struct_field_type(Type *t, isize index) {
t = base_type(type_deref(t));
GB_ASSERT(t->kind == Type_Struct);