mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Misc small refactors: Superfluous std::, trailing commas in lists, whitespace, missing breaks, import order
This commit is contained in:
parent
a77d4e281f
commit
2f78e9549a
@ -244,7 +244,7 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices,
|
|||||||
jsonItem["end"] = item.location().end;
|
jsonItem["end"] = item.location().end;
|
||||||
if (item.m_modifierDepth != 0)
|
if (item.m_modifierDepth != 0)
|
||||||
jsonItem["modifierDepth"] = static_cast<int>(item.m_modifierDepth);
|
jsonItem["modifierDepth"] = static_cast<int>(item.m_modifierDepth);
|
||||||
std::string jumpType = item.getJumpTypeAsString();
|
string jumpType = item.getJumpTypeAsString();
|
||||||
if (!jumpType.empty())
|
if (!jumpType.empty())
|
||||||
jsonItem["jumpType"] = jumpType;
|
jsonItem["jumpType"] = jumpType;
|
||||||
if (name == "PUSHLIB")
|
if (name == "PUSHLIB")
|
||||||
@ -286,7 +286,7 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices,
|
|||||||
|
|
||||||
for (size_t i = 0; i < m_subs.size(); ++i)
|
for (size_t i = 0; i < m_subs.size(); ++i)
|
||||||
{
|
{
|
||||||
std::stringstream hexStr;
|
stringstream hexStr;
|
||||||
hexStr << hex << i;
|
hexStr << hex << i;
|
||||||
data[hexStr.str()] = m_subs[i]->assemblyJSON(_sourceIndices, /*_includeSourceList = */false);
|
data[hexStr.str()] = m_subs[i]->assemblyJSON(_sourceIndices, /*_includeSourceList = */false);
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ Assembly& Assembly::optimise(OptimiserSettings const& _settings)
|
|||||||
|
|
||||||
map<u256, u256> const& Assembly::optimiseInternal(
|
map<u256, u256> const& Assembly::optimiseInternal(
|
||||||
OptimiserSettings const& _settings,
|
OptimiserSettings const& _settings,
|
||||||
std::set<size_t> _tagsReferencedFromOutside
|
set<size_t> _tagsReferencedFromOutside
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (m_tagReplacements)
|
if (m_tagReplacements)
|
||||||
|
@ -42,8 +42,8 @@ namespace
|
|||||||
|
|
||||||
string toStringInHex(u256 _value)
|
string toStringInHex(u256 _value)
|
||||||
{
|
{
|
||||||
std::stringstream hexStr;
|
stringstream hexStr;
|
||||||
hexStr << std::uppercase << hex << _value;
|
hexStr << uppercase << hex << _value;
|
||||||
return hexStr.str();
|
return hexStr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength, Precision _precision)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
case VerbatimBytecode:
|
case VerbatimBytecode:
|
||||||
return std::get<2>(*m_verbatimBytecode).size();
|
return get<2>(*m_verbatimBytecode).size();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ size_t AssemblyItem::opcodeCount() const noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssemblyItem::computeSourceMapping(
|
string AssemblyItem::computeSourceMapping(
|
||||||
AssemblyItems const& _items,
|
AssemblyItems const& _items,
|
||||||
map<string, unsigned> const& _sourceIndicesMap
|
map<string, unsigned> const& _sourceIndicesMap
|
||||||
)
|
)
|
||||||
|
@ -94,7 +94,6 @@ using namespace solidity::langutil;
|
|||||||
using namespace solidity::frontend;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
using solidity::util::errinfo_comment;
|
using solidity::util::errinfo_comment;
|
||||||
using solidity::util::toHex;
|
|
||||||
|
|
||||||
static int g_compilerStackCounts = 0;
|
static int g_compilerStackCounts = 0;
|
||||||
|
|
||||||
@ -241,7 +240,7 @@ void CompilerStack::setModelCheckerSettings(ModelCheckerSettings _settings)
|
|||||||
m_modelCheckerSettings = _settings;
|
m_modelCheckerSettings = _settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerStack::setLibraries(std::map<std::string, util::h160> const& _libraries)
|
void CompilerStack::setLibraries(map<string, util::h160> const& _libraries)
|
||||||
{
|
{
|
||||||
if (m_stackState >= ParsedAndImported)
|
if (m_stackState >= ParsedAndImported)
|
||||||
solThrow(CompilerError, "Must set libraries before parsing.");
|
solThrow(CompilerError, "Must set libraries before parsing.");
|
||||||
@ -814,7 +813,6 @@ Json::Value CompilerStack::generatedSources(string const& _contractName, bool _r
|
|||||||
sources[0]["id"] = sourceIndex;
|
sources[0]["id"] = sourceIndex;
|
||||||
sources[0]["language"] = "Yul";
|
sources[0]["language"] = "Yul";
|
||||||
sources[0]["contents"] = std::move(source);
|
sources[0]["contents"] = std::move(source);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sources;
|
return sources;
|
||||||
@ -851,7 +849,7 @@ string const* CompilerStack::runtimeSourceMapping(string const& _contractName) c
|
|||||||
return c.runtimeSourceMapping ? &*c.runtimeSourceMapping : nullptr;
|
return c.runtimeSourceMapping ? &*c.runtimeSourceMapping : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const CompilerStack::filesystemFriendlyName(string const& _contractName) const
|
string const CompilerStack::filesystemFriendlyName(string const& _contractName) const
|
||||||
{
|
{
|
||||||
if (m_stackState < AnalysisPerformed)
|
if (m_stackState < AnalysisPerformed)
|
||||||
solThrow(CompilerError, "No compiled contracts found.");
|
solThrow(CompilerError, "No compiled contracts found.");
|
||||||
@ -865,7 +863,7 @@ std::string const CompilerStack::filesystemFriendlyName(string const& _contractN
|
|||||||
contract.second.contract != matchContract.contract)
|
contract.second.contract != matchContract.contract)
|
||||||
{
|
{
|
||||||
// If it does, then return its fully-qualified name, made fs-friendly
|
// If it does, then return its fully-qualified name, made fs-friendly
|
||||||
std::string friendlyName = boost::algorithm::replace_all_copy(_contractName, "/", "_");
|
string friendlyName = boost::algorithm::replace_all_copy(_contractName, "/", "_");
|
||||||
boost::algorithm::replace_all(friendlyName, ":", "_");
|
boost::algorithm::replace_all(friendlyName, ":", "_");
|
||||||
boost::algorithm::replace_all(friendlyName, ".", "_");
|
boost::algorithm::replace_all(friendlyName, ".", "_");
|
||||||
return friendlyName;
|
return friendlyName;
|
||||||
@ -1117,7 +1115,7 @@ ContractDefinition const& CompilerStack::contractDefinition(string const& _contr
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t CompilerStack::functionEntryPoint(
|
size_t CompilerStack::functionEntryPoint(
|
||||||
std::string const& _contractName,
|
string const& _contractName,
|
||||||
FunctionDefinition const& _function
|
FunctionDefinition const& _function
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -1287,8 +1285,8 @@ bool onlySafeExperimentalFeaturesActivated(set<ExperimentalFeature> const& featu
|
|||||||
|
|
||||||
void CompilerStack::assemble(
|
void CompilerStack::assemble(
|
||||||
ContractDefinition const& _contract,
|
ContractDefinition const& _contract,
|
||||||
std::shared_ptr<evmasm::Assembly> _assembly,
|
shared_ptr<evmasm::Assembly> _assembly,
|
||||||
std::shared_ptr<evmasm::Assembly> _runtimeAssembly
|
shared_ptr<evmasm::Assembly> _runtimeAssembly
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solAssert(m_stackState >= AnalysisPerformed, "");
|
solAssert(m_stackState >= AnalysisPerformed, "");
|
||||||
@ -1599,7 +1597,7 @@ string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
static_assert(sizeof(m_optimiserSettings.expectedExecutionsPerDeployment) <= sizeof(Json::LargestUInt), "Invalid word size.");
|
static_assert(sizeof(m_optimiserSettings.expectedExecutionsPerDeployment) <= sizeof(Json::LargestUInt), "Invalid word size.");
|
||||||
solAssert(static_cast<Json::LargestUInt>(m_optimiserSettings.expectedExecutionsPerDeployment) < std::numeric_limits<Json::LargestUInt>::max(), "");
|
solAssert(static_cast<Json::LargestUInt>(m_optimiserSettings.expectedExecutionsPerDeployment) < numeric_limits<Json::LargestUInt>::max(), "");
|
||||||
meta["settings"]["optimizer"]["runs"] = Json::Value(Json::LargestUInt(m_optimiserSettings.expectedExecutionsPerDeployment));
|
meta["settings"]["optimizer"]["runs"] = Json::Value(Json::LargestUInt(m_optimiserSettings.expectedExecutionsPerDeployment));
|
||||||
|
|
||||||
/// Backwards compatibility: If set to one of the default settings, do not provide details.
|
/// Backwards compatibility: If set to one of the default settings, do not provide details.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
# (c) solidity contributors.
|
# (c) solidity contributors.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Bash script to test the import/exports.
|
# Bash script to test the import/exports.
|
||||||
|
#
|
||||||
# ast import/export tests:
|
# ast import/export tests:
|
||||||
# - first exporting a .sol file to JSON, then loading it into the compiler
|
# - first exporting a .sol file to JSON, then loading it into the compiler
|
||||||
# and exporting it again. The second JSON should be identical to the first.
|
# and exporting it again. The second JSON should be identical to the first.
|
||||||
|
@ -92,7 +92,7 @@ namespace
|
|||||||
|
|
||||||
set<frontend::InputMode> const CompilerInputModes{
|
set<frontend::InputMode> const CompilerInputModes{
|
||||||
frontend::InputMode::Compiler,
|
frontend::InputMode::Compiler,
|
||||||
frontend::InputMode::CompilerWithASTImport
|
frontend::InputMode::CompilerWithASTImport,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@ -202,7 +202,7 @@ void CommandLineInterface::handleOpcode(string const& _contract)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sout() << "Opcodes:" << endl;
|
sout() << "Opcodes:" << endl;
|
||||||
sout() << std::uppercase << evmasm::disassemble(m_compiler->object(_contract).bytecode, m_options.output.evmVersion);
|
sout() << uppercase << evmasm::disassemble(m_compiler->object(_contract).bytecode, m_options.output.evmVersion);
|
||||||
sout() << endl;
|
sout() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,8 +351,8 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra
|
|||||||
solAssert(CompilerInputModes.count(m_options.input.mode) == 1);
|
solAssert(CompilerInputModes.count(m_options.input.mode) == 1);
|
||||||
|
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
std::string suffix;
|
string suffix;
|
||||||
std::string title;
|
string title;
|
||||||
|
|
||||||
if (_natspecDev)
|
if (_natspecDev)
|
||||||
{
|
{
|
||||||
@ -369,7 +369,7 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra
|
|||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
std::string output = jsonPrint(
|
string output = jsonPrint(
|
||||||
removeNullMembers(
|
removeNullMembers(
|
||||||
_natspecDev ?
|
_natspecDev ?
|
||||||
m_compiler->natspecDev(_contract) :
|
m_compiler->natspecDev(_contract) :
|
||||||
@ -461,7 +461,7 @@ void CommandLineInterface::readInputFiles()
|
|||||||
for (boost::filesystem::path const& allowedDirectory: m_options.input.allowedDirectories)
|
for (boost::filesystem::path const& allowedDirectory: m_options.input.allowedDirectories)
|
||||||
m_fileReader.allowDirectory(allowedDirectory);
|
m_fileReader.allowDirectory(allowedDirectory);
|
||||||
|
|
||||||
map<std::string, set<boost::filesystem::path>> collisions =
|
map<string, set<boost::filesystem::path>> collisions =
|
||||||
m_fileReader.detectSourceUnitNameCollisions(m_options.input.paths);
|
m_fileReader.detectSourceUnitNameCollisions(m_options.input.paths);
|
||||||
if (!collisions.empty())
|
if (!collisions.empty())
|
||||||
{
|
{
|
||||||
@ -551,7 +551,7 @@ map<string, Json::Value> CommandLineInterface::parseAstFromInput()
|
|||||||
|
|
||||||
for (auto& src: ast["sources"].getMemberNames())
|
for (auto& src: ast["sources"].getMemberNames())
|
||||||
{
|
{
|
||||||
std::string astKey = ast["sources"][src].isMember("ast") ? "ast" : "AST";
|
string astKey = ast["sources"][src].isMember("ast") ? "ast" : "AST";
|
||||||
|
|
||||||
astAssert(ast["sources"][src].isMember(astKey), "astkey is not member");
|
astAssert(ast["sources"][src].isMember(astKey), "astkey is not member");
|
||||||
astAssert(ast["sources"][src][astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'");
|
astAssert(ast["sources"][src][astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'");
|
||||||
@ -671,6 +671,7 @@ void CommandLineInterface::processInput()
|
|||||||
case InputMode::CompilerWithASTImport:
|
case InputMode::CompilerWithASTImport:
|
||||||
compile();
|
compile();
|
||||||
outputCompilationResults();
|
outputCompilationResults();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include <libsolidity/interface/CompilerStack.h>
|
#include <libsolidity/interface/CompilerStack.h>
|
||||||
#include <libsolidity/interface/DebugSettings.h>
|
#include <libsolidity/interface/DebugSettings.h>
|
||||||
#include <libsolidity/interface/FileReader.h>
|
#include <libsolidity/interface/FileReader.h>
|
||||||
#include <libsolidity/interface/UniversalCallback.h>
|
|
||||||
#include <libsolidity/interface/SMTSolverCommand.h>
|
#include <libsolidity/interface/SMTSolverCommand.h>
|
||||||
|
#include <libsolidity/interface/UniversalCallback.h>
|
||||||
#include <libyul/YulStack.h>
|
#include <libyul/YulStack.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -926,7 +926,7 @@ void CommandLineParser::processArgs()
|
|||||||
g_strStrictAssembly,
|
g_strStrictAssembly,
|
||||||
g_strYul,
|
g_strYul,
|
||||||
g_strImportAst,
|
g_strImportAst,
|
||||||
g_strLSP
|
g_strLSP,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (m_args.count(g_strHelp) > 0)
|
if (m_args.count(g_strHelp) > 0)
|
||||||
@ -1048,7 +1048,7 @@ void CommandLineParser::processArgs()
|
|||||||
if (m_args.count(g_strRevertStrings))
|
if (m_args.count(g_strRevertStrings))
|
||||||
{
|
{
|
||||||
string revertStringsString = m_args[g_strRevertStrings].as<string>();
|
string revertStringsString = m_args[g_strRevertStrings].as<string>();
|
||||||
std::optional<RevertStrings> revertStrings = revertStringsFromString(revertStringsString);
|
optional<RevertStrings> revertStrings = revertStringsFromString(revertStringsString);
|
||||||
if (!revertStrings)
|
if (!revertStrings)
|
||||||
solThrow(
|
solThrow(
|
||||||
CommandLineValidationError,
|
CommandLineValidationError,
|
||||||
@ -1142,7 +1142,7 @@ void CommandLineParser::processArgs()
|
|||||||
if (m_args.count(g_strEVMVersion))
|
if (m_args.count(g_strEVMVersion))
|
||||||
{
|
{
|
||||||
string versionOptionStr = m_args[g_strEVMVersion].as<string>();
|
string versionOptionStr = m_args[g_strEVMVersion].as<string>();
|
||||||
std::optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString(versionOptionStr);
|
optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString(versionOptionStr);
|
||||||
if (!versionOption)
|
if (!versionOption)
|
||||||
solThrow(CommandLineValidationError, "Invalid option for --" + g_strEVMVersion + ": " + versionOptionStr);
|
solThrow(CommandLineValidationError, "Invalid option for --" + g_strEVMVersion + ": " + versionOptionStr);
|
||||||
m_options.output.evmVersion = *versionOption;
|
m_options.output.evmVersion = *versionOption;
|
||||||
|
@ -56,7 +56,7 @@ enum class InputMode
|
|||||||
StandardJson,
|
StandardJson,
|
||||||
Linker,
|
Linker,
|
||||||
Assembler,
|
Assembler,
|
||||||
LanguageServer
|
LanguageServer,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompilerOutputs
|
struct CompilerOutputs
|
||||||
@ -295,4 +295,4 @@ private:
|
|||||||
boost::program_options::variables_map m_args;
|
boost::program_options::variables_map m_args;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace solidity::frontend
|
||||||
|
Loading…
Reference in New Issue
Block a user