mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CommandLineParser: Initialize inputMode and perform generic validations earlier
This commit is contained in:
parent
30796b8957
commit
4a8a003b3d
@ -838,6 +838,37 @@ bool CommandLineParser::parseArgs(int _argc, char const* const* _argv, bool _int
|
|||||||
|
|
||||||
bool CommandLineParser::processArgs()
|
bool CommandLineParser::processArgs()
|
||||||
{
|
{
|
||||||
|
if (!checkMutuallyExclusive({
|
||||||
|
g_strStandardJSON,
|
||||||
|
g_strLink,
|
||||||
|
g_strAssemble,
|
||||||
|
g_strStrictAssembly,
|
||||||
|
g_strYul,
|
||||||
|
g_strImportAst,
|
||||||
|
}))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (m_args.count(g_strStandardJSON) > 0)
|
||||||
|
m_options.input.mode = InputMode::StandardJson;
|
||||||
|
else if (m_args.count(g_strAssemble) > 0 || m_args.count(g_strStrictAssembly) > 0 || m_args.count(g_strYul) > 0)
|
||||||
|
m_options.input.mode = InputMode::Assembler;
|
||||||
|
else if (m_args.count(g_strLink) > 0)
|
||||||
|
m_options.input.mode = InputMode::Linker;
|
||||||
|
else if (m_args.count(g_strImportAst) > 0)
|
||||||
|
m_options.input.mode = InputMode::CompilerWithASTImport;
|
||||||
|
else
|
||||||
|
m_options.input.mode = InputMode::Compiler;
|
||||||
|
|
||||||
|
if (
|
||||||
|
m_args.count(g_strExperimentalViaIR) > 0 &&
|
||||||
|
m_options.input.mode != InputMode::Compiler &&
|
||||||
|
m_options.input.mode != InputMode::CompilerWithASTImport
|
||||||
|
)
|
||||||
|
{
|
||||||
|
serr() << "The option --" << g_strExperimentalViaIR << " is only supported in the compiler mode." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!checkMutuallyExclusive({g_strColor, g_strNoColor}))
|
if (!checkMutuallyExclusive({g_strColor, g_strNoColor}))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -856,6 +887,26 @@ bool CommandLineParser::processArgs()
|
|||||||
if (!checkMutuallyExclusive({g_strStopAfter, option}))
|
if (!checkMutuallyExclusive({g_strStopAfter, option}))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (
|
||||||
|
m_options.input.mode != InputMode::Compiler &&
|
||||||
|
m_options.input.mode != InputMode::CompilerWithASTImport &&
|
||||||
|
m_options.input.mode != InputMode::Assembler
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!m_args[g_strOptimizeRuns].defaulted())
|
||||||
|
{
|
||||||
|
serr() << "Option --" << g_strOptimizeRuns << " is only valid in compiler and assembler modes." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (string const& option: {g_strOptimize, g_strNoOptimizeYul, g_strOptimizeYul, g_strYulOptimizations})
|
||||||
|
if (m_args.count(option) > 0)
|
||||||
|
{
|
||||||
|
serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_args.count(g_strColor) > 0)
|
if (m_args.count(g_strColor) > 0)
|
||||||
m_options.formatting.coloredOutput = true;
|
m_options.formatting.coloredOutput = true;
|
||||||
else if (m_args.count(g_strNoColor) > 0)
|
else if (m_args.count(g_strNoColor) > 0)
|
||||||
@ -950,60 +1001,9 @@ bool CommandLineParser::processArgs()
|
|||||||
m_options.output.stopAfter = CompilerStack::State::Parsed;
|
m_options.output.stopAfter = CompilerStack::State::Parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMutuallyExclusive({
|
|
||||||
g_strStandardJSON,
|
|
||||||
g_strLink,
|
|
||||||
g_strAssemble,
|
|
||||||
g_strStrictAssembly,
|
|
||||||
g_strYul,
|
|
||||||
g_strImportAst,
|
|
||||||
}))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (m_args.count(g_strStandardJSON) > 0)
|
|
||||||
m_options.input.mode = InputMode::StandardJson;
|
|
||||||
else if (m_args.count(g_strAssemble) > 0 || m_args.count(g_strStrictAssembly) > 0 || m_args.count(g_strYul) > 0)
|
|
||||||
m_options.input.mode = InputMode::Assembler;
|
|
||||||
else if (m_args.count(g_strLink) > 0)
|
|
||||||
m_options.input.mode = InputMode::Linker;
|
|
||||||
else if (m_args.count(g_strImportAst) > 0)
|
|
||||||
m_options.input.mode = InputMode::CompilerWithASTImport;
|
|
||||||
else
|
|
||||||
m_options.input.mode = InputMode::Compiler;
|
|
||||||
|
|
||||||
if (
|
|
||||||
m_args.count(g_strExperimentalViaIR) > 0 &&
|
|
||||||
m_options.input.mode != InputMode::Compiler &&
|
|
||||||
m_options.input.mode != InputMode::CompilerWithASTImport
|
|
||||||
)
|
|
||||||
{
|
|
||||||
serr() << "The option --" << g_strExperimentalViaIR << " is only supported in the compiler mode." << endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parseInputPathsAndRemappings())
|
if (!parseInputPathsAndRemappings())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (
|
|
||||||
m_options.input.mode != InputMode::Compiler &&
|
|
||||||
m_options.input.mode != InputMode::CompilerWithASTImport &&
|
|
||||||
m_options.input.mode != InputMode::Assembler
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!m_args[g_strOptimizeRuns].defaulted())
|
|
||||||
{
|
|
||||||
serr() << "Option --" << g_strOptimizeRuns << " is only valid in compiler and assembler modes." << endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (string const& option: {g_strOptimize, g_strNoOptimizeYul, g_strOptimizeYul, g_strYulOptimizations})
|
|
||||||
if (m_args.count(option) > 0)
|
|
||||||
{
|
|
||||||
serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_options.input.mode == InputMode::StandardJson)
|
if (m_options.input.mode == InputMode::StandardJson)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user