MCPcopy Create free account
hub / github.com/beefytech/Beef / GetAddr

Method GetAddr

IDEHelper/Compiler/CeDebugger.cpp:2405–2555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2403}
2404
2405CeTypedValue CeDebugger::GetAddr(BfConstant* constant, BfType* type)
2406{
2407 auto module = mCeMachine->mCeModule;
2408 auto ceContext = mCeMachine->mCurContext;
2409
2410 if (constant->mConstType == BfConstType_GlobalVar)
2411 {
2412 auto globalVar = (BfGlobalVar*)constant;
2413
2414 String varName(globalVar->mName);
2415
2416 if (varName.StartsWith("__bfStrObj"))
2417 {
2418 int stringId = atoi(varName.c_str() + 10);
2419 auto addr = ceContext->GetString(stringId);
2420 return CeTypedValue(addr, globalVar->mType);
2421 }
2422 else if (varName.StartsWith("__bfStrData"))
2423 {
2424 auto stringType = module->ResolveTypeDef(module->mCompiler->mStringTypeDef)->ToTypeInstance();
2425 int stringId = atoi(varName.c_str() + 11);
2426 auto addr = ceContext->GetString(stringId) + stringType->mInstSize;
2427 return CeTypedValue(addr, globalVar->mType);
2428 }
2429
2430 CeStaticFieldInfo* fieldInfo = NULL;
2431 if (ceContext->mStaticFieldMap.TryAdd(globalVar->mName, NULL, &fieldInfo))
2432 {
2433 auto dbgTypeInfo = GetDbgTypeInfo(globalVar->mType);
2434 if (dbgTypeInfo != NULL)
2435 {
2436 uint8* ptr = ceContext->CeMalloc(dbgTypeInfo->mType->mSize);
2437 if (dbgTypeInfo->mType->mSize > 0)
2438 memset(ptr, 0, dbgTypeInfo->mType->mSize);
2439 fieldInfo->mAddr = (addr_ce)(ptr - ceContext->mMemory.mVals);
2440 }
2441 else
2442 fieldInfo->mAddr = 0;
2443 }
2444 return CeTypedValue(fieldInfo->mAddr, globalVar->mType);
2445 }
2446 else if (constant->mTypeCode == BfTypeCode_StringId)
2447 {
2448 auto stringType = module->ResolveTypeDef(module->mCompiler->mStringTypeDef)->ToTypeInstance();
2449 if ((type != NULL) && (type->IsPointer()))
2450 {
2451 BfType* charType = module->GetPrimitiveType(BfTypeCode_Char8);
2452 BfType* charPtrType = module->CreatePointerType(charType);
2453 auto addr = ceContext->GetString(constant->mInt32) + stringType->mInstSize;
2454 return CeTypedValue(addr, module->mBfIRBuilder->MapType(charPtrType));
2455 }
2456 else
2457 {
2458 auto addr = ceContext->GetString(constant->mInt32);
2459 return CeTypedValue(addr, module->mBfIRBuilder->MapType(stringType));
2460 }
2461 }
2462 else if (constant->mConstType == BfConstType_AggCE)

Callers 5

GetBreakpointAddrMethod · 0.45
LoadValueMethod · 0.45
DoInvocationMethod · 0.45
PerformAssignmentMethod · 0.45
GetBreakpointAddrMethod · 0.45

Calls 15

CeTypedValueClass · 0.85
CeMallocMethod · 0.80
CreatePointerTypeMethod · 0.80
MapTypeMethod · 0.80
GetConstantByIdMethod · 0.80
StartsWithMethod · 0.45
c_strMethod · 0.45
GetStringMethod · 0.45
ToTypeInstanceMethod · 0.45
ResolveTypeDefMethod · 0.45
TryAddMethod · 0.45
IsPointerMethod · 0.45

Tested by

no test coverage detected