| 2274 | } |
| 2275 | |
| 2276 | IObject *Object::GetMethod(name_t name) |
| 2277 | { |
| 2278 | // Return the function(?) object which would be called if the named property is called, |
| 2279 | // or nullptr if that would require invoking a getter. Does not verify that the object |
| 2280 | // is callable, and does not support primitive values (even in the unusual case that Call |
| 2281 | // has been implemented via the value's base/prototype). |
| 2282 | bool dynamic_only = false; |
| 2283 | for (Object *that = this; that; that = that->mBase) |
| 2284 | { |
| 2285 | if (auto field = that->FindField(name)) |
| 2286 | { |
| 2287 | if (field->symbol != SYM_DYNAMIC) |
| 2288 | return (dynamic_only || field->symbol != SYM_OBJECT) ? nullptr : field->object; |
| 2289 | if (auto func = field->prop->Method()) |
| 2290 | return func; // Method takes precedence over any inherited value or getter. |
| 2291 | if (field->prop->Getter()) |
| 2292 | dynamic_only = true; // Getter takes precedence over any inherited value. |
| 2293 | } |
| 2294 | } |
| 2295 | return nullptr; |
| 2296 | } |
| 2297 | |
| 2298 | bool Object::HasMethod(name_t aName) |
| 2299 | { |