mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[solc] Improve parameter checks for --import-asm-json.
This commit is contained in:
parent
ed9c09b2e2
commit
9721c82569
@ -205,8 +205,7 @@ void CommandLineInterface::handleIR(string const& _contractName)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.ir)
|
||||
@ -225,8 +224,7 @@ void CommandLineInterface::handleIROptimized(string const& _contractName)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.irOptimized)
|
||||
@ -245,8 +243,7 @@ void CommandLineInterface::handleEwasm(string const& _contractName)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.ewasm)
|
||||
@ -286,8 +283,7 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.signatureHashes)
|
||||
@ -326,8 +322,7 @@ void CommandLineInterface::handleABI(string const& _contract)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.abi)
|
||||
@ -344,8 +339,7 @@ void CommandLineInterface::handleStorageLayout(string const& _contract)
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.storageLayout)
|
||||
@ -362,8 +356,7 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport , ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
bool enabled = false;
|
||||
@ -942,8 +935,7 @@ void CommandLineInterface::handleAst()
|
||||
{
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport, ""
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport
|
||||
);
|
||||
|
||||
if (!m_options.compiler.outputs.astCompactJson)
|
||||
@ -1193,7 +1185,8 @@ void CommandLineInterface::outputCompilationResults()
|
||||
handleCombinedJSON();
|
||||
|
||||
// do we need AST output?
|
||||
handleAst();
|
||||
if (m_options.input.mode != InputMode::CompilerWithEvmAssemblyJsonImport)
|
||||
handleAst();
|
||||
|
||||
if (
|
||||
!m_compiler->compilationSuccessful() &&
|
||||
@ -1233,15 +1226,19 @@ void CommandLineInterface::outputCompilationResults()
|
||||
handleGasEstimation(contract);
|
||||
|
||||
handleBytecode(contract);
|
||||
handleIR(contract);
|
||||
handleIROptimized(contract);
|
||||
handleEwasm(contract);
|
||||
handleSignatureHashes(contract);
|
||||
handleMetadata(contract);
|
||||
handleABI(contract);
|
||||
handleStorageLayout(contract);
|
||||
handleNatspec(true, contract);
|
||||
handleNatspec(false, contract);
|
||||
|
||||
if (m_options.input.mode != InputMode::CompilerWithEvmAssemblyJsonImport)
|
||||
{
|
||||
handleIR(contract);
|
||||
handleIROptimized(contract);
|
||||
handleEwasm(contract);
|
||||
handleSignatureHashes(contract);
|
||||
handleMetadata(contract);
|
||||
handleABI(contract);
|
||||
handleStorageLayout(contract);
|
||||
handleNatspec(true, contract);
|
||||
handleNatspec(false, contract);
|
||||
}
|
||||
} // end of contracts iteration
|
||||
|
||||
if (!m_hasOutput)
|
||||
|
@ -475,6 +475,12 @@ bool CommandLineParser::parseOutputSelection()
|
||||
CompilerOutputs::componentName(&CompilerOutputs::ewasm),
|
||||
CompilerOutputs::componentName(&CompilerOutputs::ewasmIR),
|
||||
};
|
||||
static set<string> const assemblyJsonImportModeOutputs = {
|
||||
CompilerOutputs::componentName(&CompilerOutputs::asm_),
|
||||
CompilerOutputs::componentName(&CompilerOutputs::binary),
|
||||
CompilerOutputs::componentName(&CompilerOutputs::binaryRuntime),
|
||||
CompilerOutputs::componentName(&CompilerOutputs::opcodes),
|
||||
};
|
||||
|
||||
switch (_mode)
|
||||
{
|
||||
@ -483,9 +489,10 @@ bool CommandLineParser::parseOutputSelection()
|
||||
case InputMode::Version:
|
||||
solAssert(false);
|
||||
case InputMode::Compiler:
|
||||
case InputMode::CompilerWithEvmAssemblyJsonImport:
|
||||
case InputMode::CompilerWithASTImport:
|
||||
return contains(compilerModeOutputs, _outputName);
|
||||
case InputMode::CompilerWithEvmAssemblyJsonImport:
|
||||
return contains(assemblyJsonImportModeOutputs, _outputName);
|
||||
case InputMode::Assembler:
|
||||
return contains(assemblerModeOutputs, _outputName);
|
||||
case InputMode::StandardJson:
|
||||
@ -1360,7 +1367,13 @@ bool CommandLineParser::parseCombinedJsonOption()
|
||||
|
||||
set<string> requests;
|
||||
for (string const& item: boost::split(requests, m_args[g_strCombinedJson].as<string>(), boost::is_any_of(",")))
|
||||
if (CombinedJsonRequests::componentMap().count(item) == 0)
|
||||
if (m_options.input.mode == InputMode::CompilerWithEvmAssemblyJsonImport &&
|
||||
CombinedJsonRequests::componentMapAssemblyJsonImport().count(item) == 0)
|
||||
{
|
||||
serr() << "Invalid option to --" << g_strCombinedJson << ": " << item << ", for --" << g_strImportEvmAssemblerJson << endl;
|
||||
return false;
|
||||
}
|
||||
else if (CombinedJsonRequests::componentMap().count(item) == 0)
|
||||
{
|
||||
serr() << "Invalid option to --" << g_strCombinedJson << ": " << item << endl;
|
||||
return false;
|
||||
|
@ -114,6 +114,18 @@ struct CombinedJsonRequests
|
||||
friend std::ostream& operator<<(std::ostream& _out, CombinedJsonRequests const& _requests);
|
||||
|
||||
static std::string const& componentName(bool CombinedJsonRequests::* _component);
|
||||
static auto const& componentMapAssemblyJsonImport()
|
||||
{
|
||||
static std::map<std::string, bool CombinedJsonRequests::*> const components = {
|
||||
{"bin", &CombinedJsonRequests::binary},
|
||||
{"bin-runtime", &CombinedJsonRequests::binaryRuntime},
|
||||
{"opcodes", &CombinedJsonRequests::opcodes},
|
||||
{"asm", &CombinedJsonRequests::asm_},
|
||||
{"srcmap", &CombinedJsonRequests::srcMap},
|
||||
{"srcmap-runtime", &CombinedJsonRequests::srcMapRuntime},
|
||||
};
|
||||
return components;
|
||||
}
|
||||
static auto const& componentMap()
|
||||
{
|
||||
static std::map<std::string, bool CombinedJsonRequests::*> const components = {
|
||||
|
Loading…
Reference in New Issue
Block a user