2014-10-25 15:13:40 +00:00
|
|
|
/*
|
2016-11-18 23:13:20 +00:00
|
|
|
This file is part of solidity.
|
2014-10-25 15:13:40 +00:00
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is free software: you can redistribute it and/or modify
|
2014-10-25 15:13:40 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is distributed in the hope that it will be useful,
|
2014-10-25 15:13:40 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2016-11-18 23:13:20 +00:00
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-25 15:13:40 +00:00
|
|
|
*/
|
2020-07-17 14:54:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0
|
2014-10-25 15:13:40 +00:00
|
|
|
/**
|
|
|
|
* @author Christian <c@ethdev.com>
|
|
|
|
* @date 2014
|
2014-10-25 16:30:43 +00:00
|
|
|
* Solidity commandline compiler.
|
2014-10-25 15:13:40 +00:00
|
|
|
*/
|
2014-10-10 14:37:54 +00:00
|
|
|
|
2019-03-28 12:07:52 +00:00
|
|
|
#include <solc/CommandLineInterface.h>
|
2021-08-09 09:36:29 +00:00
|
|
|
|
|
|
|
#include <liblangutil/Exceptions.h>
|
|
|
|
|
2019-03-28 12:07:52 +00:00
|
|
|
#include <boost/exception/all.hpp>
|
2021-08-09 09:36:29 +00:00
|
|
|
|
2016-08-30 11:29:37 +00:00
|
|
|
#include <clocale>
|
2015-08-19 23:09:39 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
2021-08-09 09:36:29 +00:00
|
|
|
using namespace solidity;
|
2014-12-08 15:42:56 +00:00
|
|
|
|
2016-08-30 19:32:30 +00:00
|
|
|
/*
|
2016-08-31 20:00:46 +00:00
|
|
|
The equivalent of setlocale(LC_ALL, "C") is called before any user code is run.
|
2016-08-30 19:32:30 +00:00
|
|
|
If the user has an invalid environment setting then it is possible for the call
|
|
|
|
to set locale to fail, so there are only two possible actions, the first is to
|
|
|
|
throw a runtime exception and cause the program to quit (default behaviour),
|
|
|
|
or the second is to modify the environment to something sensible (least
|
|
|
|
surprising behaviour).
|
|
|
|
|
|
|
|
The follow code produces the least surprising behaviour. It will use the user
|
|
|
|
specified default locale if it is valid, and if not then it will modify the
|
|
|
|
environment the process is running in to use a sensible default. This also means
|
|
|
|
that users do not need to install language packs for their OS.
|
|
|
|
*/
|
2017-08-09 11:44:53 +00:00
|
|
|
static void setDefaultOrCLocale()
|
2016-08-30 15:13:21 +00:00
|
|
|
{
|
2016-08-30 19:32:30 +00:00
|
|
|
#if __unix__
|
2016-08-30 15:13:21 +00:00
|
|
|
if (!std::setlocale(LC_ALL, ""))
|
|
|
|
{
|
2016-08-30 11:29:37 +00:00
|
|
|
setenv("LC_ALL", "C", 1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-10 14:37:54 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2021-08-09 09:36:29 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
setDefaultOrCLocale();
|
|
|
|
solidity::frontend::CommandLineInterface cli(cin, cout, cerr);
|
2021-10-12 12:16:29 +00:00
|
|
|
return cli.run(argc, argv) ? 0 : 1;
|
2021-08-09 09:36:29 +00:00
|
|
|
}
|
|
|
|
catch (smtutil::SMTLogicError const& _exception)
|
|
|
|
{
|
|
|
|
cerr << "SMT logic error:" << endl;
|
|
|
|
cerr << boost::diagnostic_information(_exception);
|
2021-06-13 13:53:16 +00:00
|
|
|
return 1;
|
2021-08-09 09:36:29 +00:00
|
|
|
}
|
|
|
|
catch (langutil::UnimplementedFeatureError const& _exception)
|
|
|
|
{
|
|
|
|
cerr << "Unimplemented feature:" << endl;
|
|
|
|
cerr << boost::diagnostic_information(_exception);
|
2014-12-09 16:39:34 +00:00
|
|
|
return 1;
|
2021-08-09 09:36:29 +00:00
|
|
|
}
|
|
|
|
catch (langutil::InternalCompilerError const& _exception)
|
2015-08-19 23:09:39 +00:00
|
|
|
{
|
2021-08-09 09:36:29 +00:00
|
|
|
cerr << "Internal compiler error:" << endl;
|
|
|
|
cerr << boost::diagnostic_information(_exception);
|
|
|
|
return 1;
|
2015-08-19 23:09:39 +00:00
|
|
|
}
|
|
|
|
catch (boost::exception const& _exception)
|
|
|
|
{
|
2021-08-09 09:36:29 +00:00
|
|
|
cerr << "Uncaught exception:" << endl;
|
|
|
|
cerr << boost::diagnostic_information(_exception) << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (std::exception const& _exception)
|
|
|
|
{
|
|
|
|
cerr << "Uncaught exception:" << endl;
|
|
|
|
cerr << boost::diagnostic_information(_exception) << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
cerr << "Uncaught exception" << endl;
|
|
|
|
cerr << boost::current_exception_diagnostic_information() << endl;
|
|
|
|
return 1;
|
2015-08-19 23:09:39 +00:00
|
|
|
}
|
2014-10-10 14:37:54 +00:00
|
|
|
}
|