| 4206 | } |
| 4207 | |
| 4208 | bool AddFunctionCallNode(const char* pos, const char* funcName, unsigned int callArgCount, bool silent) |
| 4209 | { |
| 4210 | unsigned int funcNameHash = ~0u; |
| 4211 | |
| 4212 | FunctionInfo *fInfo = NULL; |
| 4213 | FunctionType *fType = NULL; |
| 4214 | |
| 4215 | NodeZeroOP *funcAddr = NULL; |
| 4216 | TypeInfo *forcedParentType = NULL; |
| 4217 | |
| 4218 | // If we are inside member function, transform function name to a member function name (they have priority over global functions) |
| 4219 | // But it's important not to do it if we have function namespace name or it is a constructor name |
| 4220 | if(newType && funcName && !currNamespace && !SelectTypeByName(InplaceStr(funcName))) |
| 4221 | { |
| 4222 | unsigned int hash = newType->nameHash, hashBase = ~0u; |
| 4223 | hash = StringHashContinue(hash, "::"); |
| 4224 | hash = StringHashContinue(hash, funcName); |
| 4225 | |
| 4226 | if(newType->genericBase) |
| 4227 | { |
| 4228 | hashBase = newType->genericBase->nameHash; |
| 4229 | hashBase = StringHashContinue(hashBase, "::"); |
| 4230 | hashBase = StringHashContinue(hashBase, funcName); |
| 4231 | } |
| 4232 | |
| 4233 | FunctionInfo **info = funcMap.find(hash); |
| 4234 | if(info || (newType->genericBase && funcMap.find(hashBase))) |
| 4235 | { |
| 4236 | forcedParentType = newType; |
| 4237 | // If function is found, change function name hash to member function name hash |
| 4238 | funcNameHash = info ? hash : hashBase; |
| 4239 | |
| 4240 | // Take "this" pointer |
| 4241 | FunctionInfo *currFunc = currDefinedFunc.back(); |
| 4242 | TypeInfo *temp = CodeInfo::GetReferenceType(newType); |
| 4243 | assert(currFunc->extraParam); |
| 4244 | CodeInfo::nodeList.push_back(new NodeGetAddress(currFunc->extraParam, currFunc->allParamSize, temp)); |
| 4245 | CodeInfo::nodeList.push_back(new NodeDereference()); |
| 4246 | // "this" pointer will be passed as extra parameter |
| 4247 | funcAddr = CodeInfo::nodeList.back(); |
| 4248 | CodeInfo::nodeList.pop_back(); |
| 4249 | } |
| 4250 | } |
| 4251 | // Handle type(auto ref) -> type, if no user function is defined. |
| 4252 | if(!silent && callArgCount == 1 && CodeInfo::nodeList.back()->typeInfo == typeObject && funcName) |
| 4253 | { |
| 4254 | // Find class by name |
| 4255 | TypeInfo *autoRefToType = SelectTypeByName(InplaceStr(funcName)); |
| 4256 | // If class wasn't found, try all other types |
| 4257 | for(unsigned int i = 0; i < CodeInfo::typeInfo.size() && !autoRefToType; i++) |
| 4258 | { |
| 4259 | if(CodeInfo::typeInfo[i]->GetFullNameHash() == GetStringHash(funcName)) |
| 4260 | autoRefToType = CodeInfo::typeInfo[i]; |
| 4261 | } |
| 4262 | // If a type was found |
| 4263 | if(autoRefToType) |
| 4264 | { |
| 4265 | // Call user function |
no test coverage detected