mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce namespace langutil in liblangutil directory.
Also:
- Use {}-style list initialisation for SourceLocation construction
- Introduce new system includes
- Changes the API of the Scanner to take source as value (with move) as opposed to as a reference
This commit is contained in:
committed by
Alex Beregszaszi
parent
80371e2d25
commit
d67322a186
@@ -30,6 +30,7 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::eth;
|
||||
|
||||
namespace dev
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::eth;
|
||||
|
||||
namespace dev
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
|
||||
#include <test/Options.h>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace langutil
|
||||
{
|
||||
namespace test
|
||||
{
|
||||
@@ -45,6 +43,5 @@ BOOST_AUTO_TEST_CASE(test_fail)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
}
|
||||
} // end namespaces
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace dev::solidity::test;
|
||||
|
||||
@@ -127,7 +128,7 @@ string AnalysisFramework::formatError(Error const& _error) const
|
||||
return SourceReferenceFormatter::formatExceptionInformation(
|
||||
_error,
|
||||
(_error.type() == Error::Type::Warning) ? "Warning" : "Error",
|
||||
[&](std::string const& _sourceName) -> solidity::Scanner const& { return m_compiler.scanner(_sourceName); }
|
||||
[&](std::string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class AnalysisFramework
|
||||
{
|
||||
|
||||
protected:
|
||||
virtual std::pair<SourceUnit const*, ErrorList>
|
||||
virtual std::pair<SourceUnit const*, langutil::ErrorList>
|
||||
parseAnalyseAndReturnError(
|
||||
std::string const& _source,
|
||||
bool _reportWarnings = false,
|
||||
@@ -56,10 +56,10 @@ protected:
|
||||
|
||||
SourceUnit const* parseAndAnalyse(std::string const& _source);
|
||||
bool success(std::string const& _source);
|
||||
ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
|
||||
langutil::ErrorList expectError(std::string const& _source, bool _warning = false, bool _allowMultiple = false);
|
||||
|
||||
std::string formatErrors() const;
|
||||
std::string formatError(Error const& _error) const;
|
||||
std::string formatError(langutil::Error const& _error) const;
|
||||
|
||||
static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name);
|
||||
static FunctionTypePointer retrieveFunctionBySignature(
|
||||
@@ -68,7 +68,7 @@ protected:
|
||||
);
|
||||
|
||||
// filter out the warnings in m_warningsToFilter or all warnings if _includeWarnings is false
|
||||
ErrorList filterErrors(ErrorList const& _errorList, bool _includeWarnings) const;
|
||||
langutil::ErrorList filterErrors(langutil::ErrorList const& _errorList, bool _includeWarnings) const;
|
||||
|
||||
std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"};
|
||||
dev::solidity::CompilerStack m_compiler;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::eth;
|
||||
|
||||
namespace dev
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
|
||||
namespace
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
{
|
||||
bool searchErrorMessage(Error const& _err, std::string const& _substr);
|
||||
bool searchErrorMessage(langutil::Error const& _err, std::string const& _substr);
|
||||
/// Checks that all provided errors are of the given type and have a given substring in their
|
||||
/// description.
|
||||
/// If the expectations are not met, returns a nonempty description, otherwise an empty string.
|
||||
std::string searchErrors(ErrorList const& _errors, std::vector<std::pair<Error::Type, std::string>> const& _expectations);
|
||||
std::string searchErrors(langutil::ErrorList const& _errors, std::vector<std::pair<langutil::Error::Type, std::string>> const& _expectations);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <libsolidity/interface/SourceReferenceFormatter.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::eth;
|
||||
using namespace dev::solidity;
|
||||
using namespace dev::test;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <test/Options.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -72,13 +72,13 @@ public:
|
||||
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
|
||||
if (!m_compiler.compile())
|
||||
{
|
||||
auto scannerFromSourceName = [&](std::string const& _sourceName) -> solidity::Scanner const& { return m_compiler.scanner(_sourceName); };
|
||||
auto scannerFromSourceName = [&](std::string const& _sourceName) -> langutil::Scanner const& { return m_compiler.scanner(_sourceName); };
|
||||
SourceReferenceFormatter formatter(std::cerr, scannerFromSourceName);
|
||||
|
||||
for (auto const& error: m_compiler.errors())
|
||||
formatter.printExceptionInformation(
|
||||
*error,
|
||||
(error->type() == Error::Type::Warning) ? "Warning" : "Error"
|
||||
(error->type() == langutil::Error::Type::Warning) ? "Warning" : "Error"
|
||||
);
|
||||
BOOST_ERROR("Compiling contract failed");
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <test/Options.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <libdevcore/Exceptions.h>
|
||||
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <test/libsolidity/ErrorCheck.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace solidity;
|
||||
using namespace dev::solidity::test;
|
||||
using namespace dev::solidity::test::formatting;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <tuple>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
|
||||
@@ -27,13 +27,17 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace langutil
|
||||
{
|
||||
class Scanner;
|
||||
class Error;
|
||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
{
|
||||
namespace assembly
|
||||
{
|
||||
struct AsmAnalysisInfo;
|
||||
@@ -44,7 +48,7 @@ namespace yul
|
||||
namespace test
|
||||
{
|
||||
|
||||
void printErrors(solidity::ErrorList const& _errors, solidity::Scanner const& _scanner);
|
||||
void printErrors(langutil::ErrorList const& _errors, langutil::Scanner const& _scanner);
|
||||
std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>>
|
||||
parse(std::string const& _source, bool _yul = true);
|
||||
solidity::assembly::Block disambiguate(std::string const& _source, bool _yul = true);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
#include <test/Options.h>
|
||||
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
|
||||
#include <libyul/optimiser/BlockFlattener.h>
|
||||
#include <libyul/optimiser/VarDeclPropagator.h>
|
||||
#include <libyul/optimiser/Disambiguator.h>
|
||||
@@ -41,12 +44,10 @@
|
||||
#include <libyul/optimiser/RedundantAssignEliminator.h>
|
||||
#include <libyul/optimiser/Suite.h>
|
||||
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <libsolidity/inlineasm/AsmPrinter.h>
|
||||
#include <libsolidity/inlineasm/AsmParser.h>
|
||||
#include <libsolidity/inlineasm/AsmAnalysis.h>
|
||||
#include <libsolidity/interface/SourceReferenceFormatter.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@@ -54,6 +55,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::yul;
|
||||
using namespace dev::yul::test;
|
||||
using namespace dev::solidity;
|
||||
|
||||
@@ -19,14 +19,17 @@
|
||||
|
||||
#include <test/libsolidity/TestCase.h>
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
class Scanner;
|
||||
class Error;
|
||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
{
|
||||
class Scanner;
|
||||
class Error;
|
||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||
namespace assembly
|
||||
{
|
||||
struct AsmAnalysisInfo;
|
||||
@@ -58,7 +61,7 @@ private:
|
||||
bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted);
|
||||
void disambiguate();
|
||||
|
||||
static void printErrors(std::ostream& _stream, solidity::ErrorList const& _errors, solidity::Scanner const& _scanner);
|
||||
static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors, langutil::Scanner const& _scanner);
|
||||
|
||||
std::string m_source;
|
||||
bool m_yul = false;
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
*/
|
||||
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <libsolidity/inlineasm/AsmAnalysis.h>
|
||||
#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <libsolidity/parsing/Parser.h>
|
||||
#include <libsolidity/inlineasm/AsmData.h>
|
||||
#include <libsolidity/inlineasm/AsmParser.h>
|
||||
#include <libsolidity/inlineasm/AsmPrinter.h>
|
||||
#include <libsolidity/interface/SourceReferenceFormatter.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
#include <libyul/optimiser/BlockFlattener.h>
|
||||
#include <libyul/optimiser/Disambiguator.h>
|
||||
@@ -58,6 +58,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace dev::solidity::assembly;
|
||||
using namespace dev::yul;
|
||||
|
||||
Reference in New Issue
Block a user