Function that retrieves variable address
| 1318 | |
| 1319 | // Function that retrieves variable address |
| 1320 | void AddGetAddressNode(const char* pos, InplaceStr varName) |
| 1321 | { |
| 1322 | CodeInfo::lastKnownStartPos = pos; |
| 1323 | |
| 1324 | unsigned int hash = GetStringHash(varName.begin, varName.end); |
| 1325 | HashMap<VariableInfo*>::Node *curr = SelectVariableByName(varName); |
| 1326 | |
| 1327 | if(!curr) |
| 1328 | { |
| 1329 | int fID = -1; |
| 1330 | if(newType) |
| 1331 | { |
| 1332 | // Construct function name in a for of Class::Function |
| 1333 | unsigned int hash = newType->nameHash; |
| 1334 | hash = StringHashContinue(hash, "::"); |
| 1335 | hash = StringHashContinue(hash, varName.begin, varName.end); |
| 1336 | |
| 1337 | fID = CodeInfo::FindFunctionByName(hash, CodeInfo::funcInfo.size()-1); |
| 1338 | if(CodeInfo::FindFunctionByName(hash, fID - 1) != -1) |
| 1339 | { |
| 1340 | FunctionInfo *fInfo = CodeInfo::funcInfo[fID]; |
| 1341 | GetFunctionContext(pos, fInfo, true); |
| 1342 | fInfo->pure = false; |
| 1343 | CodeInfo::nodeList.push_back(new NodeFunctionProxy(fInfo, pos, false, true)); |
| 1344 | return; |
| 1345 | } |
| 1346 | // If a member function is not found, try an accessor |
| 1347 | if(fID == -1) |
| 1348 | { |
| 1349 | hash = StringHashContinue(hash, "$"); |
| 1350 | |
| 1351 | fID = CodeInfo::FindFunctionByName(hash, CodeInfo::funcInfo.size()-1); |
| 1352 | |
| 1353 | if(fID == -1 && newType->genericBase) |
| 1354 | { |
| 1355 | unsigned int hash = newType->genericBase->nameHash; |
| 1356 | hash = StringHashContinue(hash, "::"); |
| 1357 | hash = StringHashContinue(hash, varName.begin, varName.end); |
| 1358 | hash = StringHashContinue(hash, "$"); |
| 1359 | fID = CodeInfo::FindFunctionByName(hash, CodeInfo::funcInfo.size()-1); |
| 1360 | } |
| 1361 | if(fID != -1) |
| 1362 | { |
| 1363 | AddGetAddressNode(pos, InplaceStr("this", 4)); |
| 1364 | CodeInfo::nodeList.push_back(new NodeDereference()); |
| 1365 | AddMemberAccessNode(pos, varName); |
| 1366 | return; |
| 1367 | } |
| 1368 | } |
| 1369 | } |
| 1370 | if(fID == -1) |
| 1371 | { |
| 1372 | FunctionSelect f; |
| 1373 | NamespaceSelect(varName, f); |
| 1374 | hash = f.curr ? f.curr->value->nameHash : ~0u; |
| 1375 | fID = f.curr ? f.curr->value->indexInArr : -1; |
| 1376 | } |
| 1377 | if(fID == -1) |
no test coverage detected