| 13496 | } |
| 13497 | |
| 13498 | BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bool isVolatile) |
| 13499 | { |
| 13500 | if (!typedValue.IsAddr()) |
| 13501 | return typedValue; |
| 13502 | |
| 13503 | PopulateType(typedValue.mType); |
| 13504 | if ((typedValue.mType->IsValuelessType()) || (typedValue.mType->IsVar())) |
| 13505 | return BfTypedValue(mBfIRBuilder->GetFakeVal(), typedValue.mType, false); |
| 13506 | |
| 13507 | if (typedValue.mValue.IsConst()) |
| 13508 | { |
| 13509 | auto constantValue = mBfIRBuilder->GetConstant(typedValue.mValue); |
| 13510 | if (constantValue != NULL) |
| 13511 | { |
| 13512 | if (constantValue->mConstType == BfConstType_GlobalVar) |
| 13513 | { |
| 13514 | auto globalVar = (BfGlobalVar*)constantValue; |
| 13515 | if (globalVar->mName[0] == '#') |
| 13516 | { |
| 13517 | BfTypedValue result = GetCompilerFieldValue(globalVar->mName); |
| 13518 | if (result) |
| 13519 | { |
| 13520 | // We want to avoid 'unreachable code' issues from values that |
| 13521 | // are technically constant but change depending on compilation context |
| 13522 | if (mCurMethodState != NULL) |
| 13523 | { |
| 13524 | auto checkScope = mCurMethodState->mCurScope; |
| 13525 | while (checkScope != NULL) |
| 13526 | { |
| 13527 | checkScope->mSupressNextUnreachable = true; |
| 13528 | checkScope = checkScope->mPrevScope; |
| 13529 | } |
| 13530 | } |
| 13531 | return result; |
| 13532 | } |
| 13533 | |
| 13534 | if (!mIsComptimeModule) |
| 13535 | return GetDefaultTypedValue(typedValue.mType); |
| 13536 | } |
| 13537 | } |
| 13538 | |
| 13539 | if ((mIsComptimeModule) && (mCompiler->mCeMachine->mDebugger != NULL) && (mCompiler->mCeMachine->mDebugger->mCurDbgState != NULL)) |
| 13540 | { |
| 13541 | auto ceDebugger = mCompiler->mCeMachine->mDebugger; |
| 13542 | auto ceContext = ceDebugger->mCurDbgState->mCeContext; |
| 13543 | auto activeFrame = ceDebugger->mCurDbgState->mActiveFrame; |
| 13544 | |
| 13545 | auto ceTypedValue = ceDebugger->GetAddr(constantValue); |
| 13546 | if (ceTypedValue) |
| 13547 | { |
| 13548 | if ((typedValue.mType->IsObjectOrInterface()) || (typedValue.mType->IsPointer()) || (typedValue.mType->IsRef())) |
| 13549 | { |
| 13550 | void* data = ceContext->GetMemoryPtr((addr_ce)ceTypedValue.mAddr, sizeof(addr_ce)); |
| 13551 | if (data == NULL) |
| 13552 | { |
| 13553 | Fail("Invalid address", refNode); |
| 13554 | return GetDefaultTypedValue(typedValue.mType); |
| 13555 | } |
no test coverage detected