| 135 | } |
| 136 | |
| 137 | std::string Pattern::toString() const |
| 138 | { |
| 139 | std::stringstream s; |
| 140 | switch (m_type) |
| 141 | { |
| 142 | case Operation: |
| 143 | // Note: This function is exclusively used for debugging. |
| 144 | s << instructionInfo(m_instruction, EVMVersion()).name; |
| 145 | break; |
| 146 | case Push: |
| 147 | if (m_data) |
| 148 | s << "PUSH " << std::hex << data(); |
| 149 | else |
| 150 | s << "PUSH "; |
| 151 | break; |
| 152 | case UndefinedItem: |
| 153 | s << "ANY"; |
| 154 | break; |
| 155 | default: |
| 156 | if (m_data) |
| 157 | s << "t=" << std::dec << m_type << " d=" << std::hex << data(); |
| 158 | else |
| 159 | s << "t=" << std::dec << m_type << " d: nullptr"; |
| 160 | break; |
| 161 | } |
| 162 | if (!m_requireDataMatch) |
| 163 | s << " ~"; |
| 164 | if (m_matchGroup) |
| 165 | s << "[" << std::dec << m_matchGroup << "]"; |
| 166 | s << "("; |
| 167 | for (Pattern const& p: m_arguments) |
| 168 | s << p.toString() << ", "; |
| 169 | s << ")"; |
| 170 | return s.str(); |
| 171 | } |
| 172 | |
| 173 | bool Pattern::matchesBaseItem(AssemblyItem const* _item) const |
| 174 | { |
no test coverage detected