Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1 | //===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===// |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jim Ingham | 6c68fb4 | 2010-09-30 00:54:27 +0000 | [diff] [blame] | 9 | #include "clang/AST/Type.h" |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 10 | |
Jim Ingham | 5a36912 | 2010-09-28 01:25:32 +0000 | [diff] [blame] | 11 | #include "lldb/Core/Log.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 12 | #include "lldb/Core/Module.h" |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 13 | #include "lldb/Core/PluginManager.h" |
Jim Ingham | 6c68fb4 | 2010-09-30 00:54:27 +0000 | [diff] [blame] | 14 | #include "lldb/Core/ValueObject.h" |
| 15 | #include "lldb/Symbol/ClangASTContext.h" |
Jim Ingham | 61be090 | 2011-05-02 18:13:59 +0000 | [diff] [blame] | 16 | #include "lldb/Symbol/Type.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 17 | #include "lldb/Symbol/TypeList.h" |
Jim Ingham | 5a36912 | 2010-09-28 01:25:32 +0000 | [diff] [blame] | 18 | #include "lldb/Target/ObjCLanguageRuntime.h" |
Sean Callanan | 7277284 | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 19 | #include "lldb/Target/Target.h" |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace lldb; |
| 22 | using namespace lldb_private; |
| 23 | |
| 24 | //---------------------------------------------------------------------- |
| 25 | // Destructor |
| 26 | //---------------------------------------------------------------------- |
| 27 | ObjCLanguageRuntime::~ObjCLanguageRuntime() |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) : |
Sean Callanan | 226b70c | 2012-03-08 02:39:03 +0000 | [diff] [blame] | 32 | LanguageRuntime (process), |
Sean Callanan | c09d9d8 | 2012-09-15 01:05:12 +0000 | [diff] [blame] | 33 | m_has_new_literals_and_indexing (eLazyBoolCalculate), |
| 34 | m_isa_to_descriptor_cache_is_up_to_date (false) |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 35 | { |
| 36 | |
Jim Ingham | 5a36912 | 2010-09-28 01:25:32 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void |
| 40 | ObjCLanguageRuntime::AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr) |
| 41 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 42 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
Jim Ingham | 5a36912 | 2010-09-28 01:25:32 +0000 | [diff] [blame] | 43 | if (log) |
| 44 | { |
| 45 | log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr); |
| 46 | } |
| 47 | m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr)); |
| 48 | } |
| 49 | |
| 50 | lldb::addr_t |
| 51 | ObjCLanguageRuntime::LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t selector) |
| 52 | { |
| 53 | MsgImplMap::iterator pos, end = m_impl_cache.end(); |
| 54 | pos = m_impl_cache.find (ClassAndSel(class_addr, selector)); |
| 55 | if (pos != end) |
| 56 | return (*pos).second; |
| 57 | return LLDB_INVALID_ADDRESS; |
| 58 | } |
Jim Ingham | 61be090 | 2011-05-02 18:13:59 +0000 | [diff] [blame] | 59 | |
| 60 | void |
| 61 | ObjCLanguageRuntime::AddToClassNameCache (lldb::addr_t class_addr, const char *name, lldb::TypeSP type_sp) |
| 62 | { |
| 63 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
| 64 | if (log) |
| 65 | { |
| 66 | log->Printf ("Caching: class 0x%llx name: %s.", class_addr, name); |
| 67 | } |
| 68 | |
| 69 | TypeAndOrName class_type_or_name; |
| 70 | |
Greg Clayton | 85ae2e1 | 2011-10-18 23:36:41 +0000 | [diff] [blame] | 71 | if (type_sp) |
Jim Ingham | 61be090 | 2011-05-02 18:13:59 +0000 | [diff] [blame] | 72 | class_type_or_name.SetTypeSP (type_sp); |
| 73 | else if (name && *name != '\0') |
| 74 | class_type_or_name.SetName (name); |
| 75 | else |
| 76 | return; |
| 77 | m_class_name_cache.insert (std::pair<lldb::addr_t,TypeAndOrName> (class_addr, class_type_or_name)); |
| 78 | } |
| 79 | |
| 80 | void |
| 81 | ObjCLanguageRuntime::AddToClassNameCache (lldb::addr_t class_addr, const TypeAndOrName &class_type_or_name) |
| 82 | { |
| 83 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); |
| 84 | if (log) |
| 85 | { |
| 86 | log->Printf ("Caching: class 0x%llx name: %s.", class_addr, class_type_or_name.GetName().AsCString()); |
| 87 | } |
| 88 | |
| 89 | m_class_name_cache.insert (std::pair<lldb::addr_t,TypeAndOrName> (class_addr, class_type_or_name)); |
| 90 | } |
| 91 | |
| 92 | TypeAndOrName |
| 93 | ObjCLanguageRuntime::LookupInClassNameCache (lldb::addr_t class_addr) |
| 94 | { |
| 95 | ClassNameMap::iterator pos, end = m_class_name_cache.end(); |
| 96 | pos = m_class_name_cache.find (class_addr); |
| 97 | if (pos != end) |
| 98 | return (*pos).second; |
| 99 | return TypeAndOrName (); |
| 100 | } |
Jim Ingham | d555bac | 2011-06-24 22:03:24 +0000 | [diff] [blame] | 101 | |
Sean Callanan | 7277284 | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 102 | lldb::TypeSP |
| 103 | ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name) |
| 104 | { |
| 105 | CompleteClassMap::iterator complete_class_iter = m_complete_class_cache.find(name); |
| 106 | |
| 107 | if (complete_class_iter != m_complete_class_cache.end()) |
| 108 | { |
| 109 | TypeSP ret(complete_class_iter->second); |
| 110 | |
| 111 | if (!ret) |
| 112 | m_complete_class_cache.erase(name); |
| 113 | else |
| 114 | return TypeSP(complete_class_iter->second); |
| 115 | } |
| 116 | |
| 117 | ModuleList &modules = m_process->GetTarget().GetImages(); |
| 118 | |
| 119 | SymbolContextList sc_list; |
| 120 | |
| 121 | modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list); |
| 122 | |
| 123 | if (sc_list.GetSize() == 0) |
| 124 | return TypeSP(); |
| 125 | |
| 126 | SymbolContext sc; |
| 127 | |
| 128 | sc_list.GetContextAtIndex(0, sc); |
| 129 | |
| 130 | ModuleSP module_sp(sc.module_sp); |
| 131 | |
| 132 | if (!module_sp) |
| 133 | return TypeSP(); |
| 134 | |
| 135 | const SymbolContext null_sc; |
Greg Clayton | 84db910 | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 136 | const bool exact_match = true; |
Sean Callanan | 7277284 | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 137 | const uint32_t max_matches = UINT32_MAX; |
| 138 | TypeList types; |
| 139 | |
Greg Clayton | 84db910 | 2012-03-26 23:03:23 +0000 | [diff] [blame] | 140 | module_sp->FindTypes (null_sc, |
| 141 | name, |
| 142 | exact_match, |
| 143 | max_matches, |
| 144 | types); |
Sean Callanan | 7277284 | 2012-02-22 23:57:45 +0000 | [diff] [blame] | 145 | |
| 146 | if (types.GetSize() == 1) |
| 147 | { |
| 148 | TypeSP candidate_type = types.GetTypeAtIndex(0); |
| 149 | |
| 150 | if (ClangASTContext::IsObjCClassType(candidate_type->GetClangForwardType())) |
| 151 | { |
| 152 | m_complete_class_cache[name] = TypeWP(candidate_type); |
| 153 | return candidate_type; |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | return TypeSP(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | for (uint32_t ti = 0, te = types.GetSize(); |
| 162 | ti < te; |
| 163 | ++ti) |
| 164 | { |
| 165 | TypeSP candidate_type = types.GetTypeAtIndex(ti); |
| 166 | |
| 167 | if (candidate_type->IsCompleteObjCClass() && |
| 168 | ClangASTContext::IsObjCClassType(candidate_type->GetClangForwardType())) |
| 169 | { |
| 170 | m_complete_class_cache[name] = TypeWP(candidate_type); |
| 171 | return candidate_type; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | return TypeSP(); |
| 176 | } |
| 177 | |
Jim Ingham | d555bac | 2011-06-24 22:03:24 +0000 | [diff] [blame] | 178 | size_t |
| 179 | ObjCLanguageRuntime::GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name) |
| 180 | { |
| 181 | return LLDB_INVALID_IVAR_OFFSET; |
| 182 | } |
| 183 | |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 184 | |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 185 | uint32_t |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 186 | ObjCLanguageRuntime::ParseMethodName (const char *name, |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 187 | ConstString *class_name, // Class name (with category if any) |
| 188 | ConstString *selector_name, // selector on its own |
| 189 | ConstString *name_sans_category, // Full function prototype with no category |
| 190 | ConstString *class_name_sans_category)// Class name with no category (or empty if no category as answer will be in "class_name" |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 191 | { |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 192 | if (class_name) |
| 193 | class_name->Clear(); |
| 194 | if (selector_name) |
| 195 | selector_name->Clear(); |
| 196 | if (name_sans_category) |
| 197 | name_sans_category->Clear(); |
| 198 | if (class_name_sans_category) |
| 199 | class_name_sans_category->Clear(); |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 200 | |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 201 | uint32_t result = 0; |
| 202 | |
Jim Ingham | b7f6b2f | 2011-09-08 22:13:49 +0000 | [diff] [blame] | 203 | if (IsPossibleObjCMethodName (name)) |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 204 | { |
| 205 | int name_len = strlen (name); |
| 206 | // Objective C methods must have at least: |
| 207 | // "-[" or "+[" prefix |
| 208 | // One character for a class name |
| 209 | // One character for the space between the class name |
| 210 | // One character for the method name |
| 211 | // "]" suffix |
| 212 | if (name_len >= 6 && name[name_len - 1] == ']') |
| 213 | { |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 214 | const char *selector_name_ptr = strchr (name, ' '); |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 215 | if (selector_name_ptr) |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 216 | { |
| 217 | if (class_name) |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 218 | { |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 219 | class_name->SetCStringWithLength (name + 2, selector_name_ptr - name - 2); |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 220 | ++result; |
| 221 | } |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 222 | |
| 223 | // Skip the space |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 224 | ++selector_name_ptr; |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 225 | // Extract the objective C basename and add it to the |
| 226 | // accelerator tables |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 227 | size_t selector_name_len = name_len - (selector_name_ptr - name) - 1; |
| 228 | if (selector_name) |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 229 | { |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 230 | selector_name->SetCStringWithLength (selector_name_ptr, selector_name_len); |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 231 | ++result; |
| 232 | } |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 233 | |
| 234 | // Also see if this is a "category" on our class. If so strip off the category name, |
| 235 | // and add the class name without it to the basename table. |
| 236 | |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 237 | if (name_sans_category || class_name_sans_category) |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 238 | { |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 239 | const char *open_paren = strchr (name, '('); |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 240 | if (open_paren) |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 241 | { |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 242 | if (class_name_sans_category) |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 243 | { |
Greg Clayton | 278a16b | 2012-01-19 00:52:59 +0000 | [diff] [blame] | 244 | class_name_sans_category->SetCStringWithLength (name + 2, open_paren - name - 2); |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 245 | ++result; |
| 246 | } |
Sean Callanan | b811e4b | 2012-01-19 01:10:27 +0000 | [diff] [blame] | 247 | |
| 248 | if (name_sans_category) |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 249 | { |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 250 | const char *close_paren = strchr (open_paren, ')'); |
| 251 | if (open_paren < close_paren) |
Sean Callanan | b811e4b | 2012-01-19 01:10:27 +0000 | [diff] [blame] | 252 | { |
| 253 | std::string buffer (name, open_paren - name); |
| 254 | buffer.append (close_paren + 1); |
| 255 | name_sans_category->SetCString (buffer.c_str()); |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 256 | ++result; |
Sean Callanan | b811e4b | 2012-01-19 01:10:27 +0000 | [diff] [blame] | 257 | } |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | } |
| 261 | } |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 262 | } |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 263 | } |
Greg Clayton | e42ae84 | 2012-01-19 03:24:53 +0000 | [diff] [blame] | 264 | return result; |
Jim Ingham | ff5f5ff | 2011-08-15 01:32:22 +0000 | [diff] [blame] | 265 | } |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 266 | |
| 267 | bool |
| 268 | ObjCLanguageRuntime::ClassDescriptor::IsPointerValid (lldb::addr_t value, |
| 269 | uint32_t ptr_size, |
| 270 | bool allow_NULLs, |
| 271 | bool allow_tagged, |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 272 | bool check_version_specific) const |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 273 | { |
| 274 | if (!value) |
| 275 | return allow_NULLs; |
| 276 | if ( (value % 2) == 1 && allow_tagged) |
| 277 | return true; |
| 278 | if ((value % ptr_size) == 0) |
| 279 | return (check_version_specific ? CheckPointer(value,ptr_size) : true); |
| 280 | else |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | ObjCLanguageRuntime::ObjCISA |
Sean Callanan | bc47dfc | 2012-09-11 21:44:01 +0000 | [diff] [blame] | 285 | ObjCLanguageRuntime::GetISA(const ConstString &name) |
| 286 | { |
Sean Callanan | c09d9d8 | 2012-09-15 01:05:12 +0000 | [diff] [blame] | 287 | // Try once regardless of whether the map has been brought up to date. We |
| 288 | // might have encountered the relevant isa directly. |
| 289 | for (const ISAToDescriptorMap::value_type &val : m_isa_to_descriptor_cache) |
| 290 | if (val.second && val.second->GetClassName() == name) |
| 291 | return val.first; |
| 292 | |
| 293 | // If the map is up to date and we didn't find the isa, give up. |
| 294 | if (m_isa_to_descriptor_cache_is_up_to_date) |
| 295 | return 0; |
| 296 | |
| 297 | // Try again after bringing the map up to date. |
| 298 | UpdateISAToDescriptorMap(); |
| 299 | |
Sean Callanan | bc47dfc | 2012-09-11 21:44:01 +0000 | [diff] [blame] | 300 | for (const ISAToDescriptorMap::value_type &val : m_isa_to_descriptor_cache) |
| 301 | if (val.second && val.second->GetClassName() == name) |
| 302 | return val.first; |
| 303 | |
Sean Callanan | c09d9d8 | 2012-09-15 01:05:12 +0000 | [diff] [blame] | 304 | // Now we know for sure that the class isn't there. Give up. |
Sean Callanan | bc47dfc | 2012-09-11 21:44:01 +0000 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | ObjCLanguageRuntime::ObjCISA |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 309 | ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) |
| 310 | { |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 311 | ClassDescriptorSP objc_class_sp (GetClassDescriptor(isa)); |
| 312 | if (objc_class_sp) |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 313 | { |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 314 | ClassDescriptorSP objc_super_class_sp (objc_class_sp->GetSuperclass()); |
| 315 | if (objc_super_class_sp) |
| 316 | return objc_super_class_sp->GetISA(); |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 317 | } |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 318 | return 0; |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | // TODO: should we have a transparent_kvo parameter here to say if we |
| 322 | // want to replace the KVO swizzled class with the actual user-level type? |
| 323 | ConstString |
| 324 | ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) |
| 325 | { |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 326 | ClassDescriptorSP objc_class_sp (GetNonKVOClassDescriptor(isa)); |
| 327 | if (objc_class_sp) |
| 328 | return objc_class_sp->GetClassName(); |
| 329 | return ConstString(); |
Enrico Granata | 3467d80 | 2012-09-04 18:47:54 +0000 | [diff] [blame] | 330 | } |
Greg Clayton | 77fbc81 | 2012-10-09 17:51:53 +0000 | [diff] [blame] | 331 | |
| 332 | ObjCLanguageRuntime::ClassDescriptorSP |
| 333 | ObjCLanguageRuntime::GetClassDescriptor (ValueObject& in_value) |
| 334 | { |
| 335 | ObjCISA isa = GetISA(in_value); |
| 336 | if (isa) |
| 337 | return GetClassDescriptor (isa); |
| 338 | return ClassDescriptorSP(); |
| 339 | } |
| 340 | |
| 341 | ObjCLanguageRuntime::ClassDescriptorSP |
| 342 | ObjCLanguageRuntime::GetClassDescriptor (ObjCISA isa) |
| 343 | { |
| 344 | ClassDescriptorSP objc_class_sp; |
| 345 | if (isa) |
| 346 | { |
| 347 | ObjCLanguageRuntime::ISAToDescriptorIterator found = m_isa_to_descriptor_cache.find(isa); |
| 348 | ObjCLanguageRuntime::ISAToDescriptorIterator end = m_isa_to_descriptor_cache.end(); |
| 349 | |
| 350 | if (found != end && found->second) |
| 351 | return found->second; |
| 352 | |
| 353 | objc_class_sp = CreateClassDescriptor(isa); |
| 354 | if (objc_class_sp && objc_class_sp->IsValid()) |
| 355 | m_isa_to_descriptor_cache[isa] = objc_class_sp; |
| 356 | } |
| 357 | return objc_class_sp; |
| 358 | } |
| 359 | |
| 360 | ObjCLanguageRuntime::ClassDescriptorSP |
| 361 | ObjCLanguageRuntime::GetNonKVOClassDescriptor (ObjCISA isa) |
| 362 | { |
| 363 | if (isa) |
| 364 | { |
| 365 | ClassDescriptorSP objc_class_sp = GetClassDescriptor (isa); |
| 366 | if (objc_class_sp && objc_class_sp->IsValid()) |
| 367 | { |
| 368 | if (objc_class_sp->IsKVO()) |
| 369 | { |
| 370 | ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass()); |
| 371 | if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid()) |
| 372 | return non_kvo_objc_class_sp; |
| 373 | } |
| 374 | else |
| 375 | return objc_class_sp; |
| 376 | } |
| 377 | } |
| 378 | return ClassDescriptorSP(); |
| 379 | } |
| 380 | |
| 381 | |
| 382 | |