Skip to content

Commit e1246c9

Browse files
committed
fixup! [libevmasm] Add support to import evm assembly json.
1 parent a1e1afb commit e1246c9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

libevmasm/Assembly.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
533533
if (_json.isMember("sourceList"))
534534
{
535535
solRequire(_json["sourceList"].isArray(), AssemblyImportException, "Optional member 'sourceList' is not an array.");
536-
for (Json::Value const& sourceListItem: _json["sourceList"])
537-
solRequire(sourceListItem.isString(), AssemblyImportException, "The 'sourceList' array contains an item that is not a string.");
536+
for (Json::Value const& sourceName: _json["sourceList"])
537+
solRequire(sourceName.isString(), AssemblyImportException, "The 'sourceList' array contains an item that is not a string.");
538538
}
539539
}
540540
else
@@ -548,14 +548,14 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
548548
if (_json.isMember("sourceList"))
549549
{
550550
solAssert(_level == 0);
551-
for (Json::Value const& it: _json["sourceList"])
551+
for (Json::Value const& sourceName: _json["sourceList"])
552552
{
553553
solRequire(
554-
std::find(sourceList.begin(), sourceList.end(), it.asString()) == sourceList.end(),
554+
std::find(sourceList.begin(), sourceList.end(), sourceName.asString()) == sourceList.end(),
555555
AssemblyImportException,
556556
"Items in 'sourceList' array are not unique."
557557
);
558-
sourceList.emplace_back(it.asString());
558+
sourceList.emplace_back(sourceName.asString());
559559
}
560560
}
561561
else
@@ -577,22 +577,22 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
577577
{
578578
solRequire(dataIter.key().isString(), AssemblyImportException, "Key inside '.data' is not a string.");
579579
std::string dataItemID = dataIter.key().asString();
580-
Json::Value const& code = data[dataItemID];
581-
if (code.isString())
580+
Json::Value const& dataItem = data[dataItemID];
581+
if (dataItem.isString())
582582
{
583583
solRequire(
584-
code.asString().empty() || !fromHex(code.asString()).empty(),
584+
dataItem.asString().empty() || !fromHex(dataItem.asString()).empty(),
585585
AssemblyImportException,
586586
"Member '.data' contains a value for '" + dataItemID + "' that is not a valid hexadecimal string."
587587
);
588-
result->m_data[h256(fromHex(dataItemID))] = fromHex(code.asString());
588+
result->m_data[h256(fromHex(dataItemID))] = fromHex(dataItem.asString());
589589
}
590-
else if (code.isObject())
590+
else if (dataItem.isObject())
591591
{
592592
size_t index = static_cast<size_t>(std::stoi(dataItemID));
593593
if (result->m_subs.size() <= index)
594594
result->m_subs.resize(index + 1);
595-
std::shared_ptr<Assembly> subassembly(Assembly::fromJSON(code, sourceList, _level + 1).first);
595+
std::shared_ptr<Assembly> subassembly(Assembly::fromJSON(dataItem, sourceList, _level + 1).first);
596596
solAssert(subassembly);
597597
result->m_subs[index] = subassembly;
598598
}

0 commit comments

Comments
 (0)