[yul-phaser] Don't return exit code from Phaser::main() and just assume 0 if it does not throw.

This commit is contained in:
Kamil Śliwak 2020-02-28 03:58:26 +01:00
parent d86b5019dc
commit 760e7c3cc5
3 changed files with 14 additions and 19 deletions

View File

@ -142,16 +142,15 @@ CharStream ProgramFactory::loadSource(string const& _sourcePath)
return CharStream(sourceCode, _sourcePath);
}
int Phaser::main(int _argc, char** _argv)
void Phaser::main(int _argc, char** _argv)
{
CommandLineParsingResult parsingResult = parseCommandLine(_argc, _argv);
if (parsingResult.exitCode != 0)
return parsingResult.exitCode;
optional<po::variables_map> arguments = parseCommandLine(_argc, _argv);
if (!arguments.has_value())
return;
initialiseRNG(parsingResult.arguments);
initialiseRNG(arguments.value());
runAlgorithm(parsingResult.arguments);
return 0;
runAlgorithm(arguments.value());
}
Phaser::CommandLineDescription Phaser::buildCommandLineDescription()
@ -198,7 +197,7 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription()
return {keywordDescription, positionalDescription};
}
Phaser::CommandLineParsingResult Phaser::parseCommandLine(int _argc, char** _argv)
optional<po::variables_map> Phaser::parseCommandLine(int _argc, char** _argv)
{
auto [keywordDescription, positionalDescription] = buildCommandLineDescription();
@ -212,13 +211,13 @@ Phaser::CommandLineParsingResult Phaser::parseCommandLine(int _argc, char** _arg
if (arguments.count("help") > 0)
{
cout << keywordDescription << endl;
return {0, move(arguments)};
return nullopt;
}
if (arguments.count("input-file") == 0)
assertThrow(false, NoInputFiles, "Missing argument: input-file.");
return {0, arguments};
return arguments;
}
void Phaser::initialiseRNG(po::variables_map const& _arguments)

View File

@ -25,6 +25,7 @@
#include <istream>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
@ -128,7 +129,7 @@ private:
class Phaser
{
public:
static int main(int argc, char** argv);
static void main(int argc, char** argv);
private:
struct CommandLineDescription
@ -137,14 +138,8 @@ private:
boost::program_options::positional_options_description positionalDescription;
};
struct CommandLineParsingResult
{
int exitCode;
boost::program_options::variables_map arguments;
};
static CommandLineDescription buildCommandLineDescription();
static CommandLineParsingResult parseCommandLine(int _argc, char** _argv);
static std::optional<boost::program_options::variables_map> parseCommandLine(int _argc, char** _argv);
static void initialiseRNG(boost::program_options::variables_map const& _arguments);
static void runAlgorithm(boost::program_options::variables_map const& _arguments);

View File

@ -26,7 +26,8 @@ int main(int argc, char** argv)
{
try
{
return solidity::phaser::Phaser::main(argc, argv);
solidity::phaser::Phaser::main(argc, argv);
return 0;
}
catch (boost::program_options::error const& exception)
{