| 539 | } |
| 540 | |
| 541 | std::string AssemblyItem::computeSourceMapping( |
| 542 | AssemblyItems const& _items, |
| 543 | std::map<std::string, unsigned> const& _sourceIndicesMap |
| 544 | ) |
| 545 | { |
| 546 | std::string ret; |
| 547 | |
| 548 | int prevStart = -1; |
| 549 | int prevLength = -1; |
| 550 | int prevSourceIndex = -1; |
| 551 | int prevModifierDepth = -1; |
| 552 | char prevJump = 0; |
| 553 | |
| 554 | for (auto const& item: _items) |
| 555 | { |
| 556 | if (!ret.empty()) |
| 557 | ret += ";"; |
| 558 | |
| 559 | SourceLocation const& location = item.location(); |
| 560 | int length = location.start != -1 && location.end != -1 ? location.end - location.start : -1; |
| 561 | int sourceIndex = |
| 562 | (location.sourceName && _sourceIndicesMap.count(*location.sourceName)) ? |
| 563 | static_cast<int>(_sourceIndicesMap.at(*location.sourceName)) : |
| 564 | -1; |
| 565 | char jump = '-'; |
| 566 | if (item.getJumpType() == evmasm::AssemblyItem::JumpType::IntoFunction || item.type() == CallF || item.type() == JumpF) |
| 567 | jump = 'i'; |
| 568 | else if (item.getJumpType() == evmasm::AssemblyItem::JumpType::OutOfFunction || item.type() == RetF) |
| 569 | jump = 'o'; |
| 570 | int modifierDepth = static_cast<int>(item.m_modifierDepth); |
| 571 | |
| 572 | unsigned components = 5; |
| 573 | if (modifierDepth == prevModifierDepth) |
| 574 | { |
| 575 | components--; |
| 576 | if (jump == prevJump) |
| 577 | { |
| 578 | components--; |
| 579 | if (sourceIndex == prevSourceIndex) |
| 580 | { |
| 581 | components--; |
| 582 | if (length == prevLength) |
| 583 | { |
| 584 | components--; |
| 585 | if (location.start == prevStart) |
| 586 | components--; |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | if (components-- > 0) |
| 593 | { |
| 594 | if (location.start != prevStart) |
| 595 | ret += std::to_string(location.start); |
| 596 | if (components-- > 0) |
| 597 | { |
| 598 | ret += ':'; |
nothing calls this directly
no test coverage detected