| 66 | } |
| 67 | |
| 68 | void CeEvaluationContext::Init(CeDebugger* ceDebugger, const StringImpl& expr, CeFormatInfo* formatInfo, BfTypedValue contextValue) |
| 69 | { |
| 70 | mDebugger = ceDebugger; |
| 71 | |
| 72 | mCallStackIdx = 0; |
| 73 | mParser = NULL; |
| 74 | mReducer = NULL; |
| 75 | mPassInstance = NULL; |
| 76 | mExprEvaluator = NULL; |
| 77 | mExprNode = NULL; |
| 78 | |
| 79 | if (expr.empty()) |
| 80 | return; |
| 81 | |
| 82 | int atPos = (int)expr.IndexOf('@'); |
| 83 | if ((atPos != -1) && (atPos < expr.mLength - 2) && (expr[atPos + 1] == '0') && (expr[atPos + 2] == 'x')) |
| 84 | { |
| 85 | bool isValid = true; |
| 86 | for (int i = 0; i < atPos; i++) |
| 87 | { |
| 88 | char c = expr[i]; |
| 89 | if ((c < '0') || (c > '9')) |
| 90 | { |
| 91 | isValid = false; |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if (isValid) |
| 97 | { |
| 98 | int parseLength = expr.mLength; |
| 99 | for (int i = 0; i < expr.mLength; i++) |
| 100 | { |
| 101 | if ((expr[i] == ',') || (::isspace((uint8)expr[i]))) |
| 102 | { |
| 103 | parseLength = i; |
| 104 | break; |
| 105 | } |
| 106 | } |
| 107 | mExprString = expr.Substring(0, parseLength); |
| 108 | |
| 109 | String typeIdStr = expr.Substring(0, atPos); |
| 110 | String addrStr = expr.Substring(atPos + 3, parseLength - atPos - 3); |
| 111 | |
| 112 | int typeId = strtol(typeIdStr.c_str(), NULL, 10); |
| 113 | int64 addrVal = strtoll(addrStr.c_str(), NULL, 16); |
| 114 | |
| 115 | if ((typeId != 0) && (addrVal != 0)) |
| 116 | { |
| 117 | auto type = ceDebugger->mCompiler->mContext->FindTypeById(typeId); |
| 118 | if (type != NULL) |
| 119 | { |
| 120 | auto module = ceDebugger->mCeMachine->mCeModule; |
| 121 | |
| 122 | if (type->IsObjectOrInterface()) |
| 123 | { |
| 124 | mResultOverride = BfTypedValue(module->mBfIRBuilder->CreateIntToPtr( |
| 125 | module->mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, (uint64)addrVal), module->mBfIRBuilder->MapType(type)), type); |
no test coverage detected