| 137 | DynamicObject::Ptr scope; |
| 138 | |
| 139 | var findFunctionCall (const CodeLocation& location, const var& targetObject, const Identifier& functionName) const |
| 140 | { |
| 141 | if (auto* o = targetObject.getDynamicObject()) |
| 142 | { |
| 143 | if (auto* prop = getPropertyPointer (*o, functionName)) |
| 144 | return *prop; |
| 145 | |
| 146 | for (auto* p = o->getProperty (getPrototypeIdentifier()).getDynamicObject(); p != nullptr; |
| 147 | p = p->getProperty (getPrototypeIdentifier()).getDynamicObject()) |
| 148 | { |
| 149 | if (auto* prop = getPropertyPointer (*p, functionName)) |
| 150 | return *prop; |
| 151 | } |
| 152 | |
| 153 | // if there's a class with an overridden DynamicObject::hasMethod, this avoids an error |
| 154 | if (o->hasMethod (functionName)) |
| 155 | return {}; |
| 156 | } |
| 157 | |
| 158 | if (targetObject.isString()) |
| 159 | if (auto* m = findRootClassProperty (StringClass::getClassName(), functionName)) |
| 160 | return *m; |
| 161 | |
| 162 | if (targetObject.isArray()) |
| 163 | if (auto* m = findRootClassProperty (ArrayClass::getClassName(), functionName)) |
| 164 | return *m; |
| 165 | |
| 166 | if (auto* m = findRootClassProperty (ObjectClass::getClassName(), functionName)) |
| 167 | return *m; |
| 168 | |
| 169 | location.throwError ("Unknown function '" + functionName.toString() + "'"); |
| 170 | return {}; |
| 171 | } |
| 172 | |
| 173 | var* findRootClassProperty (const Identifier& className, const Identifier& propName) const |
| 174 | { |
nothing calls this directly
no test coverage detected