| 338 | } |
| 339 | |
| 340 | std::string AssemblyItem::toAssemblyText(Assembly const& _assembly) const |
| 341 | { |
| 342 | std::string text; |
| 343 | switch (type()) |
| 344 | { |
| 345 | case Operation: |
| 346 | { |
| 347 | assertThrow(isValidInstruction(instruction()), AssemblyException, "Invalid instruction."); |
| 348 | text = util::toLower(instructionInfo(instruction(), _assembly.evmVersion()).name); |
| 349 | break; |
| 350 | } |
| 351 | case Push: |
| 352 | text = toHex(toCompactBigEndian(data(), 1), util::HexPrefix::Add); |
| 353 | break; |
| 354 | case PushTag: |
| 355 | { |
| 356 | auto [sub, tag] = splitForeignPushTag(); |
| 357 | if (sub.empty()) |
| 358 | text = std::string("tag_") + std::to_string(tag); |
| 359 | else |
| 360 | text = std::string("tag_") + std::to_string(sub.value) + "_" + std::to_string(tag); |
| 361 | break; |
| 362 | } |
| 363 | case Tag: |
| 364 | assertThrow(data() < 0x10000, AssemblyException, "Declaration of sub-assembly tag."); |
| 365 | text = std::string("tag_") + std::to_string(static_cast<size_t>(data())) + ":"; |
| 366 | break; |
| 367 | case PushData: |
| 368 | text = std::string("data_") + toHex(data()); |
| 369 | break; |
| 370 | case PushSub: |
| 371 | case PushSubSize: |
| 372 | { |
| 373 | std::vector<std::string> subPathComponents; |
| 374 | for (SubAssemblyID subPathComponentId: _assembly.decodeSubPath(SubAssemblyID{data()})) |
| 375 | subPathComponents.emplace_back("sub_" + std::to_string(subPathComponentId.value)); |
| 376 | text = |
| 377 | (type() == PushSub ? "dataOffset"s : "dataSize"s) + |
| 378 | "(" + |
| 379 | solidity::util::joinHumanReadable(subPathComponents, ".") + |
| 380 | ")"; |
| 381 | break; |
| 382 | } |
| 383 | case PushProgramSize: |
| 384 | text = std::string("bytecodeSize"); |
| 385 | break; |
| 386 | case PushLibraryAddress: |
| 387 | text = std::string("linkerSymbol(\"") + toHex(data()) + std::string("\")"); |
| 388 | break; |
| 389 | case PushDeployTimeAddress: |
| 390 | text = std::string("deployTimeAddress()"); |
| 391 | break; |
| 392 | case PushImmutable: |
| 393 | text = std::string("immutable(\"") + "0x" + util::toHex(toCompactBigEndian(data(), 1)) + "\")"; |
| 394 | break; |
| 395 | case AssignImmutable: |
| 396 | text = std::string("assignImmutable(\"") + "0x" + util::toHex(toCompactBigEndian(data(), 1)) + "\")"; |
| 397 | break; |
no test coverage detected