| 248 | |
| 249 | |
| 250 | void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILInstruction& instr, |
| 251 | HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence, |
| 252 | std::optional<bool> signedHint) |
| 253 | { |
| 254 | const auto& twoOperand = instr.AsTwoOperand(); |
| 255 | const auto leftExpr = twoOperand.GetLeftExpr(); |
| 256 | const auto rightExpr = twoOperand.GetRightExpr(); |
| 257 | BNOperatorPrecedence leftPrecedence = precedence; |
| 258 | switch (precedence) |
| 259 | { |
| 260 | case SubOperatorPrecedence: |
| 261 | // Treat left side of subtraction as same level as addition. This lets |
| 262 | // (a - b) - c be represented as a - b - c, but a - (b - c) does not |
| 263 | // simplify at rendering |
| 264 | leftPrecedence = AddOperatorPrecedence; |
| 265 | break; |
| 266 | case DivideOperatorPrecedence: |
| 267 | // Treat left side of divison as same level as multiplication. This lets |
| 268 | // (a / b) / c be represented as a / b / c, but a / (b / c) does not |
| 269 | // simplify at rendering |
| 270 | leftPrecedence = MultiplyOperatorPrecedence; |
| 271 | break; |
| 272 | default: |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | if (leftExpr.operation == HLIL_SPLIT) |
| 277 | { |
| 278 | const auto low = leftExpr.GetLowExpr(); |
| 279 | const auto high = leftExpr.GetHighExpr(); |
| 280 | |
| 281 | emitter.Append(OperationToken, "COMBINE"); |
| 282 | emitter.AppendOpenParen(); |
| 283 | GetExprTextInternal(high, emitter, settings); |
| 284 | emitter.Append(TextToken, ", "); |
| 285 | GetExprTextInternal(low, emitter, settings); |
| 286 | emitter.AppendCloseParen(); |
| 287 | } |
| 288 | |
| 289 | |
| 290 | if (!settings || settings->IsOptionSet(ShowTypeCasts)) |
| 291 | { |
| 292 | if (leftExpr.operation == HLIL_VAR && (operand == " + " || operand == " - ")) |
| 293 | { |
| 294 | const auto variableType = GetFunction()->GetVariableType(leftExpr.GetVariable()); |
| 295 | if (variableType) |
| 296 | { |
| 297 | const auto childType = variableType->GetChildType(); |
| 298 | if (variableType->IsPointer() && childType && childType->GetWidth() != 1) |
| 299 | { |
| 300 | emitter.AppendOpenParen(); |
| 301 | emitter.Append(TypeNameToken, "char"); |
| 302 | emitter.Append(TextToken, "*"); |
| 303 | emitter.AppendCloseParen(); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
nothing calls this directly
no test coverage detected