CommandLineInterface: Merge processInput() and actOnInput()

- The distinction between them is not as clear-cut as it should be. For example processInput() prints output in assembly mode.
This commit is contained in:
Kamil Śliwak
2021-11-02 16:31:45 +01:00
parent 93c1fe6878
commit a1c9c1e2b5
4 changed files with 21 additions and 40 deletions
+14 -33
View File
@@ -610,10 +610,10 @@ bool CommandLineInterface::processInput()
return false;
case InputMode::License:
printLicense();
return true;
break;
case InputMode::Version:
printVersion();
return true;
break;
case InputMode::StandardJson:
{
solAssert(m_standardJsonInput.has_value(), "");
@@ -621,21 +621,25 @@ bool CommandLineInterface::processInput()
StandardCompiler compiler(m_fileReader.reader(), m_options.formatting.json);
sout() << compiler.compile(move(m_standardJsonInput.value())) << endl;
m_standardJsonInput.reset();
return true;
break;
}
case InputMode::Assembler:
{
return assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine);
}
if (!assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine))
return false;
break;
case InputMode::Linker:
return link();
if (!link())
return false;
writeLinkedFiles();
break;
case InputMode::Compiler:
case InputMode::CompilerWithASTImport:
return compile();
if (!compile())
return false;
outputCompilationResults();
}
solAssert(false, "");
return false;
return !m_outputFailed;
}
void CommandLineInterface::printVersion()
@@ -883,29 +887,6 @@ void CommandLineInterface::handleAst()
}
}
bool CommandLineInterface::actOnInput()
{
switch (m_options.input.mode)
{
case InputMode::Help:
case InputMode::License:
case InputMode::Version:
case InputMode::StandardJson:
case InputMode::Assembler:
// Already done in "processInput" phase.
break;
case InputMode::Linker:
writeLinkedFiles();
break;
case InputMode::Compiler:
case InputMode::CompilerWithASTImport:
outputCompilationResults();
break;
}
return !m_outputFailed;
}
bool CommandLineInterface::link()
{
solAssert(m_options.input.mode == InputMode::Linker, "");