| 579 | |
| 580 | |
| 581 | void Demangle::DemangleChar(char& ch) |
| 582 | { |
| 583 | m_logger->LogDebug("%s: '%s'\n", __FUNCTION__, reader.GetRaw()); |
| 584 | // Basic char is just the char |
| 585 | if (reader.Peek() != '?') |
| 586 | { |
| 587 | ch = reader.Peek(); |
| 588 | reader.Consume(); |
| 589 | return; |
| 590 | } |
| 591 | reader.Consume(); |
| 592 | |
| 593 | // Hex char is ?$XX for 2 hex digits XX |
| 594 | if (reader.Peek() == '$') |
| 595 | { |
| 596 | m_logger->LogDebug("%s: Hex digit '%s'\n", __FUNCTION__, reader.GetRaw()); |
| 597 | |
| 598 | reader.Consume(); |
| 599 | char c1 = reader.Peek(); |
| 600 | reader.Consume(); |
| 601 | char c2 = reader.Peek(); |
| 602 | reader.Consume(); |
| 603 | |
| 604 | if (c1 < 'A' || c1 > 'P') |
| 605 | throw DemangleException("Invalid character"); |
| 606 | if (c2 < 'A' || c2 > 'P') |
| 607 | throw DemangleException("Invalid character"); |
| 608 | |
| 609 | uint8_t b1 = c1 - 'A'; |
| 610 | uint8_t b2 = c2 - 'A'; |
| 611 | |
| 612 | ch = (char)((b1 << 4) | b2); |
| 613 | return; |
| 614 | } |
| 615 | |
| 616 | m_logger->LogDebug("%s: Table lookup '%s'\n", __FUNCTION__, reader.GetRaw()); |
| 617 | |
| 618 | // Otherwise it's a lookup based on some big table |
| 619 | // Thanks, LLVM! |
| 620 | switch (reader.Peek()) |
| 621 | { |
| 622 | case '0': ch = ','; reader.Consume(); return; |
| 623 | case '1': ch = '/'; reader.Consume(); return; |
| 624 | case '2': ch = '\\'; reader.Consume(); return; |
| 625 | case '3': ch = ':'; reader.Consume(); return; |
| 626 | case '4': ch = '.'; reader.Consume(); return; |
| 627 | case '5': ch = ' '; reader.Consume(); return; |
| 628 | case '6': ch = '\n'; reader.Consume(); return; |
| 629 | case '7': ch = '\t'; reader.Consume(); return; |
| 630 | case '8': ch = '\''; reader.Consume(); return; |
| 631 | case '9': ch = '-'; reader.Consume(); return; |
| 632 | case 'a': ch = '\xE1'; reader.Consume(); return; |
| 633 | case 'b': ch = '\xE2'; reader.Consume(); return; |
| 634 | case 'c': ch = '\xE3'; reader.Consume(); return; |
| 635 | case 'd': ch = '\xE4'; reader.Consume(); return; |
| 636 | case 'e': ch = '\xE5'; reader.Consume(); return; |
| 637 | case 'f': ch = '\xE6'; reader.Consume(); return; |
| 638 | case 'g': ch = '\xE7'; reader.Consume(); return; |
nothing calls this directly
no test coverage detected