MCPcopy Create free account
hub / github.com/WheretIB/nullc / AddGetAddressNode

Function AddGetAddressNode

NULLC/Callbacks.cpp:1320–1463  ·  view source on GitHub ↗

Function that retrieves variable address

Source from the content-addressed store, hash-verified

1318
1319// Function that retrieves variable address
1320void 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)

Callers 13

GetFunctionContextFunction · 0.85
AddInplaceVariableFunction · 0.85
AddArrayIteratorFunction · 0.85
FunctionStartFunction · 0.85
AddFunctionCallNodeFunction · 0.85
TypeFinishFunction · 0.85
AddListGeneratorFunction · 0.85
ParseEnumFunction · 0.85
ParseAddVariableFunction · 0.85
ParseVariableFunction · 0.85

Calls 13

SelectVariableByNameFunction · 0.85
StringHashContinueFunction · 0.85
GetFunctionContextFunction · 0.85
InplaceStrClass · 0.85
AddMemberAccessNodeFunction · 0.85
NamespaceSelectFunction · 0.85
ThrowErrorFunction · 0.85
assertFunction · 0.85
AddFunctionExternalFunction · 0.85
AddGetVariableNodeFunction · 0.85
GetStringHashFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected