diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 1afcca89d..32998f121 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -75,11 +75,11 @@ unsigned Assembly::codeSize(unsigned subTagSize) const } } -void Assembly::importAssemblyItemsFromJSON(Json::Value const& _code, vector const& _sourceList) +void Assembly::importAssemblyItemsFromJSON(Json::Value const& _code, std::vector const& _sourceList) { solAssert(m_items.empty()); solRequire(_code.isArray(), AssemblyImportException, "Supplied JSON is not an array."); - for (auto current = begin(_code); current != end(_code); ++current) + for (auto current = std::begin(_code); current != std::end(_code); ++current) { auto const& item = m_items.emplace_back(createAssemblyItemFromJSON(*current, _sourceList)); if (item == Instruction::JUMPDEST) @@ -87,7 +87,7 @@ void Assembly::importAssemblyItemsFromJSON(Json::Value const& _code, vector const& _sourceList) { solRequire(_json.isObject(), AssemblyImportException, "Supplied JSON is not an object."); - static set const validMembers{"name", "begin", "end", "source", "value", "modifierDepth", "jumpType"}; + static std::set const validMembers{"name", "begin", "end", "source", "value", "modifierDepth", "jumpType"}; for (auto const& member: _json.getMemberNames()) solRequire( validMembers.count(member), @@ -104,23 +104,23 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: "Unknown member '" + member + "'. Valid members are " + solidity::util::joinHumanReadable(validMembers, ", ") + "." ); - solRequire(isOfType(_json["name"]), AssemblyImportException, "Member 'name' missing or not of type string."); + solRequire(isOfType(_json["name"]), AssemblyImportException, "Member 'name' missing or not of type string."); solRequire(isOfTypeIfExists(_json, "begin"), AssemblyImportException, "Optional member 'begin' not of type int."); solRequire(isOfTypeIfExists(_json, "end"), AssemblyImportException, "Optional member 'end' not of type int."); solRequire(isOfTypeIfExists(_json, "source"), AssemblyImportException, "Optional member 'source' not of type int."); - solRequire(isOfTypeIfExists(_json, "value"), AssemblyImportException, "Optional member 'value' not of type string."); + solRequire(isOfTypeIfExists(_json, "value"), AssemblyImportException, "Optional member 'value' not of type string."); solRequire( isOfTypeIfExists(_json, "modifierDepth"), AssemblyImportException, "Optional member 'modifierDepth' not of type int." ); solRequire( - isOfTypeIfExists(_json, "jumpType"), + isOfTypeIfExists(_json, "jumpType"), AssemblyImportException, "Optional member 'jumpType' not of type string." ); - string name = get(_json["name"]); + std::string name = get(_json["name"]); solRequire(!name.empty(), AssemblyImportException, "Member 'name' was empty."); SourceLocation location; @@ -128,16 +128,16 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: location.end = get(_json["end"]); int srcIndex = getOrDefault(_json["source"], -1); size_t modifierDepth = static_cast(getOrDefault(_json["modifierDepth"], 0)); - string value = getOrDefault(_json["value"], ""); - string jumpType = getOrDefault(_json["jumpType"], ""); + std::string value = getOrDefault(_json["value"], ""); + std::string jumpType = getOrDefault(_json["jumpType"], ""); auto updateUsedTags = [&](u256 const& data) { - m_usedTags = max(m_usedTags, static_cast(data) + 1); + m_usedTags = std::max(m_usedTags, static_cast(data) + 1); return data; }; - auto storeImmutableHash = [&](string const& _immutableName) -> h256 + auto storeImmutableHash = [&](std::string const& _immutableName) -> h256 { h256 hash(util::keccak256(_immutableName)); solAssert(m_immutables.count(hash) == 0 || m_immutables[hash] == _immutableName); @@ -145,7 +145,7 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: return hash; }; - auto storeLibraryHash = [&](string const& _libraryName) -> h256 + auto storeLibraryHash = [&](std::string const& _libraryName) -> h256 { h256 hash(util::keccak256(_libraryName)); solAssert(m_libraries.count(hash) == 0 || m_libraries[hash] == _libraryName); @@ -153,7 +153,7 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: return hash; }; - auto requireValueDefinedForInstruction = [&](string const& _name, string const& _value) + auto requireValueDefinedForInstruction = [&](std::string const& _name, std::string const& _value) { solRequire( !_value.empty(), @@ -162,7 +162,7 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: ); }; - auto requireValueUndefinedForInstruction = [&](string const& _name, string const& _value) + auto requireValueUndefinedForInstruction = [&](std::string const& _name, std::string const& _value) { solRequire( _value.empty(), @@ -174,7 +174,7 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: solRequire(srcIndex >= -1 && srcIndex < static_cast(_sourceList.size()), AssemblyImportException, "srcIndex out of bound."); if (srcIndex != -1) { - static map> sharedSourceNames; + static std::map> sharedSourceNames; if (sharedSourceNames.find(_sourceList[static_cast(srcIndex)]) == sharedSourceNames.end()) sharedSourceNames[_sourceList[static_cast(srcIndex)]] = std::make_shared(_sourceList[static_cast(srcIndex)]); location.sourceName = sharedSourceNames[_sourceList[static_cast(srcIndex)]]; @@ -492,8 +492,8 @@ Json::Value Assembly::assemblyJSON(std::vector const& _sources, boo for (size_t i = 0; i < m_subs.size(); ++i) { - stringstream hexStr; - hexStr << hex << i; + std::stringstream hexStr; + hexStr << std::hex << i; data[hexStr.str()] = m_subs[i]->assemblyJSON(_sources, false); data[hexStr.str()]["index"] = static_cast(i); } @@ -505,10 +505,10 @@ Json::Value Assembly::assemblyJSON(std::vector const& _sources, boo return root; } -std::pair, std::vector> Assembly::fromJSON(Json::Value const& _json, vector const& _sourceList, int _level) +std::pair, std::vector> Assembly::fromJSON(Json::Value const& _json, std::vector const& _sourceList, int _level) { solRequire(_json.isObject(), AssemblyImportException, "Supplied JSON is not an object."); - static set const validMembers{".code", ".data", ".auxdata", "sourceList", "index"}; + static std::set const validMembers{".code", ".data", ".auxdata", "sourceList", "index"}; for (auto const& attribute: _json.getMemberNames()) solRequire(validMembers.count(attribute), AssemblyImportException, "Unknown attribute '" + attribute + "'."); solRequire(_json.isMember(".code"), AssemblyImportException, "Member '.code' does not exist."); @@ -531,8 +531,8 @@ std::pair, std::vector> Assembly::fromJSO "Member 'sourceList' is only allowed in root JSON object." ); - shared_ptr result = make_shared(langutil::EVMVersion(), _level == 0, ""); - vector sourceList; + std::shared_ptr result = std::make_shared(langutil::EVMVersion(), _level == 0, ""); + std::vector sourceList; if (_json.isMember("sourceList")) { solAssert(_level == 0); @@ -564,7 +564,7 @@ std::pair, std::vector> Assembly::fromJSO for (Json::ValueConstIterator dataIter = data.begin(); dataIter != data.end(); dataIter++) { solRequire(dataIter.key().isString(), AssemblyImportException, "Key inside '.data' is not of type string."); - string dataItemID = dataIter.key().asString(); + std::string dataItemID = dataIter.key().asString(); Json::Value const& code = data[dataItemID]; if (code.isString()) { @@ -584,7 +584,7 @@ std::pair, std::vector> Assembly::fromJSO size_t index = static_cast(code["index"].asInt()); if (result->m_subs.size() <= index) result->m_subs.resize(index + 1); - shared_ptr subassembly(Assembly::fromJSON(code, sourceList, _level + 1).first); + std::shared_ptr subassembly(Assembly::fromJSON(code, sourceList, _level + 1).first); solAssert(subassembly); result->m_subs[index] = subassembly; } @@ -629,7 +629,7 @@ void Assembly::updatePaths(std::vector const& _parents, std::vector _sourceID) +AssemblyItem Assembly::namedTag(std::string const& _name, size_t _params, size_t _returns, std::optional _sourceID) { assertThrow(!_name.empty(), AssemblyException, "Empty named tag."); if (m_namedTags.count(_name)) diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 144787b0e..120f12a25 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -247,7 +247,7 @@ std::string AssemblyItem::getJumpTypeAsString() const } } -void AssemblyItem::setJumpType(string const& _jumpType) +void AssemblyItem::setJumpType(std::string const& _jumpType) { if (_jumpType == "[in]") m_jumpType = JumpType::IntoFunction; diff --git a/libevmasm/EVMAssemblyStack.cpp b/libevmasm/EVMAssemblyStack.cpp index 0348aff4d..ea19226f3 100644 --- a/libevmasm/EVMAssemblyStack.cpp +++ b/libevmasm/EVMAssemblyStack.cpp @@ -25,12 +25,11 @@ using namespace solidity::util; using namespace solidity::langutil; using namespace solidity::frontend; -using namespace std; namespace solidity::evmasm { -void EVMAssemblyStack::parseAndAnalyze(string const& _sourceName, string const& _source) +void EVMAssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source) { solAssert(!m_evmAssembly); m_name = _sourceName; @@ -51,29 +50,29 @@ void EVMAssemblyStack::assemble() m_sourceMapping = AssemblyItem::computeSourceMapping(m_evmAssembly->items(), sourceIndices()); if (m_evmAssembly->numSubs() > 0) { - m_evmRuntimeAssembly = make_shared(m_evmAssembly->sub(0)); + m_evmRuntimeAssembly = std::make_shared(m_evmAssembly->sub(0)); solAssert(m_evmRuntimeAssembly && !m_evmRuntimeAssembly->isCreation()); m_runtimeSourceMapping = AssemblyItem::computeSourceMapping(m_evmRuntimeAssembly->items(), sourceIndices()); m_runtimeObject = m_evmRuntimeAssembly->assemble(); } } -LinkerObject const& EVMAssemblyStack::object(string const& _contractName) const +LinkerObject const& EVMAssemblyStack::object(std::string const& _contractName) const { solAssert(_contractName == m_name); return m_object; } -LinkerObject const& EVMAssemblyStack::runtimeObject(string const& _contractName) const +LinkerObject const& EVMAssemblyStack::runtimeObject(std::string const& _contractName) const { solAssert(_contractName == m_name); return m_runtimeObject; } -map EVMAssemblyStack::sourceIndices() const +std::map EVMAssemblyStack::sourceIndices() const { solAssert(m_evmAssembly); - map indices; + std::map indices; unsigned index = 0; for (auto const& s: m_sourceList) if (s != CompilerContext::yulUtilityFileName()) @@ -84,42 +83,42 @@ map EVMAssemblyStack::sourceIndices() const return indices; } -string const* EVMAssemblyStack::sourceMapping(string const& _contractName) const +std::string const* EVMAssemblyStack::sourceMapping(std::string const& _contractName) const { solAssert(_contractName == m_name); return &m_sourceMapping; } -string const* EVMAssemblyStack::runtimeSourceMapping(string const& _contractName) const +std::string const* EVMAssemblyStack::runtimeSourceMapping(std::string const& _contractName) const { solAssert(_contractName == m_name); return &m_runtimeSourceMapping; } -Json::Value EVMAssemblyStack::assemblyJSON(string const& _contractName) const +Json::Value EVMAssemblyStack::assemblyJSON(std::string const& _contractName) const { solAssert(_contractName == m_name); solAssert(m_evmAssembly); - vector sources = sourceNames(); + std::vector sources = sourceNames(); if (find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end()) sources.emplace_back(CompilerContext::yulUtilityFileName()); return m_evmAssembly->assemblyJSON(sources); } -string EVMAssemblyStack::assemblyString(string const& _contractName, StringMap const& _sourceCodes) const +std::string EVMAssemblyStack::assemblyString(std::string const& _contractName, StringMap const& _sourceCodes) const { solAssert(_contractName == m_name); solAssert(m_evmAssembly); return m_evmAssembly->assemblyString(m_debugInfoSelection, _sourceCodes); } -string const EVMAssemblyStack::filesystemFriendlyName(string const& _contractName) const +std::string const EVMAssemblyStack::filesystemFriendlyName(std::string const& _contractName) const { solAssert(_contractName == m_name); return m_name; } -vector EVMAssemblyStack::sourceNames() const +std::vector EVMAssemblyStack::sourceNames() const { return m_sourceList; }