| 271 | |
| 272 | |
| 273 | void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevelILInstruction& instr, |
| 274 | HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence, |
| 275 | std::optional<bool> signedHint) |
| 276 | { |
| 277 | const auto& twoOperand = instr.AsTwoOperand(); |
| 278 | const auto leftExpr = twoOperand.GetLeftExpr(); |
| 279 | const auto rightExpr = twoOperand.GetRightExpr(); |
| 280 | BNOperatorPrecedence leftPrecedence = precedence; |
| 281 | switch (precedence) |
| 282 | { |
| 283 | case SubOperatorPrecedence: |
| 284 | // Treat left side of subtraction as same level as addition. This lets |
| 285 | // (a - b) - c be represented as a - b - c, but a - (b - c) does not |
| 286 | // simplify at rendering |
| 287 | leftPrecedence = AddOperatorPrecedence; |
| 288 | break; |
| 289 | case DivideOperatorPrecedence: |
| 290 | // Treat left side of divison as same level as multiplication. This lets |
| 291 | // (a / b) / c be represented as a / b / c, but a / (b / c) does not |
| 292 | // simplify at rendering |
| 293 | leftPrecedence = MultiplyOperatorPrecedence; |
| 294 | break; |
| 295 | default: |
| 296 | break; |
| 297 | } |
| 298 | |
| 299 | if (leftExpr.operation == HLIL_SPLIT) |
| 300 | { |
| 301 | const auto low = leftExpr.GetLowExpr(); |
| 302 | const auto high = leftExpr.GetHighExpr(); |
| 303 | |
| 304 | emitter.Append(OperationToken, "COMBINE"); |
| 305 | emitter.AppendOpenParen(); |
| 306 | GetExprText(high, emitter, settings); |
| 307 | emitter.Append(TextToken, ", "); |
| 308 | GetExprText(low, emitter, settings); |
| 309 | emitter.AppendCloseParen(); |
| 310 | } |
| 311 | |
| 312 | if (operand == " + " || operand == " - ") |
| 313 | { |
| 314 | const auto exprType = leftExpr.GetType(); |
| 315 | if (exprType && exprType->IsPointer()) |
| 316 | { |
| 317 | GetExprText(leftExpr, emitter, settings, MemberAndFunctionOperatorPrecedence); |
| 318 | emitter.Append(TextToken, "."); |
| 319 | emitter.Append(OperationToken, "byte_offset"); |
| 320 | emitter.AppendOpenParen(); |
| 321 | if (operand == " - ") |
| 322 | { |
| 323 | emitter.Append(OperationToken, "-"); |
| 324 | GetExprText(rightExpr, emitter, settings, UnaryOperatorPrecedence); |
| 325 | } |
| 326 | else |
| 327 | { |
| 328 | GetExprText(rightExpr, emitter, settings); |
| 329 | } |
| 330 | emitter.AppendCloseParen(); |
nothing calls this directly
no test coverage detected