aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-05-08 12:58:33 +0100
committerGitHub <noreply@github.com>2025-05-08 12:58:33 +0100
commit92df892f25832b368e29b39dda094a7357c7f3e6 (patch)
tree9f56732962285a117dc4fa6b602c89ed04ffbec8 /src/types.cpp
parent4a709086a49f97e6d22bcd441bac38169b1baa21 (diff)
parent14e25c0f2a0dea725cb098dcf9939a8d4681e7d6 (diff)
Merge pull request #5064 from harold-b/hb/objc-classes
Add support for Objective-C class implementation
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 393e35ca1..32becc446 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -729,10 +729,12 @@ gb_global Type *t_map_set_proc = nullptr;
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_id = nullptr;
gb_global Type *t_objc_SEL = nullptr;
gb_global Type *t_objc_Class = nullptr;
+gb_global Type *t_objc_Ivar = nullptr;
enum OdinAtomicMemoryOrder : i32 {
OdinAtomicMemoryOrder_relaxed = 0, // unordered
@@ -872,6 +874,29 @@ gb_internal Type *base_type(Type *t) {
return t;
}
+gb_internal Type *base_named_type(Type *t) {
+ if (t->kind != Type_Named) {
+ return t_invalid;
+ }
+
+ Type *prev_named = t;
+ t = t->Named.base;
+ for (;;) {
+ if (t == nullptr) {
+ break;
+ }
+ if (t->kind != Type_Named) {
+ break;
+ }
+ if (t == t->Named.base) {
+ return t_invalid;
+ }
+ prev_named = t;
+ t = t->Named.base;
+ }
+ return prev_named;
+}
+
gb_internal Type *base_enum_type(Type *t) {
Type *bt = base_type(t);
if (bt != nullptr &&
@@ -3327,6 +3352,15 @@ gb_internal Selection lookup_field_with_selection(Type *type_, String field_name
}
}
}
+
+ Type *objc_ivar_type = e->TypeName.objc_ivar;
+ if (objc_ivar_type != nullptr) {
+ sel = lookup_field_with_selection(objc_ivar_type, field_name, false, sel, allow_blank_ident);
+ if (sel.entity != nullptr) {
+ sel.pseudo_field = true;
+ return sel;
+ }
+ }
}
if (is_type_polymorphic(type)) {