diff options
author | Christian Parpart <christian@ethereum.org> | 2018-11-15 00:11:55 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-11-22 03:13:44 +0800 |
commit | d67322a1861d60a88151f7c25d6c3478a9a39acf (patch) | |
tree | af485e48c3436cd24e2db09a6a1bcf445605bae1 /libsolidity/interface | |
parent | 80371e2d25ce3eb868d6f75b99a54af9dc6c1583 (diff) | |
download | dexon-solidity-d67322a1861d60a88151f7c25d6c3478a9a39acf.tar.gz dexon-solidity-d67322a1861d60a88151f7c25d6c3478a9a39acf.tar.zst dexon-solidity-d67322a1861d60a88151f7c25d6c3478a9a39acf.zip |
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
Diffstat (limited to 'libsolidity/interface')
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 1 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.h | 18 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 1 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 24 | ||||
-rw-r--r-- | libsolidity/interface/GasEstimator.cpp | 1 | ||||
-rw-r--r-- | libsolidity/interface/SourceReferenceFormatter.cpp | 1 | ||||
-rw-r--r-- | libsolidity/interface/SourceReferenceFormatter.h | 14 | ||||
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 3 |
8 files changed, 40 insertions, 23 deletions
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index 26879e8b..5b6b1113 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -36,6 +36,7 @@ using namespace std; using namespace dev; +using namespace langutil; using namespace dev::solidity; namespace diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index aad65ffc..d6ee33cf 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -29,11 +29,15 @@ #include <string> #include <memory> +namespace langutil +{ +class Scanner; +} + namespace dev { namespace solidity { -class Scanner; namespace assembly { struct AsmAnalysisInfo; @@ -61,7 +65,7 @@ public: {} /// @returns the scanner used during parsing - Scanner const& scanner() const; + langutil::Scanner const& scanner() const; /// Runs parsing and analysis steps, returns false if input cannot be assembled. /// Multiple calls overwrite the previous state. @@ -69,13 +73,13 @@ public: /// Runs analysis step on the supplied block, returns false if input cannot be assembled. /// Multiple calls overwrite the previous state. - bool analyze(assembly::Block const& _block, Scanner const* _scanner = nullptr); + bool analyze(assembly::Block const& _block, langutil::Scanner const* _scanner = nullptr); /// Run the assembly step (should only be called after parseAndAnalyze). MachineAssemblyObject assemble(Machine _machine) const; /// @returns the errors generated during parsing, analysis (and potentially assembly). - ErrorList const& errors() const { return m_errors; } + langutil::ErrorList const& errors() const { return m_errors; } /// Pretty-print the input after having parsed it. std::string print() const; @@ -86,13 +90,13 @@ private: Language m_language = Language::Assembly; EVMVersion m_evmVersion; - std::shared_ptr<Scanner> m_scanner; + std::shared_ptr<langutil::Scanner> m_scanner; bool m_analysisSuccessful = false; std::shared_ptr<assembly::Block> m_parserResult; std::shared_ptr<assembly::AsmAnalysisInfo> m_analysisInfo; - ErrorList m_errors; - ErrorReporter m_errorReporter; + langutil::ErrorList m_errors; + langutil::ErrorReporter m_errorReporter; }; } diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 08a248dd..a5674705 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -58,6 +58,7 @@ using namespace std; using namespace dev; +using namespace langutil; using namespace dev::solidity; boost::optional<CompilerStack::Remapping> CompilerStack::parseRemapping(string const& _remapping) diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index a7e312ad..8c50266e 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -23,11 +23,12 @@ #pragma once -#include <liblangutil/ErrorReporter.h> #include <libsolidity/interface/ReadFile.h> -#include <liblangutil/EVMVersion.h> +#include <liblangutil/ErrorReporter.h> +#include <liblangutil/EVMVersion.h> #include <liblangutil/SourceLocation.h> + #include <libevmasm/LinkerObject.h> #include <libdevcore/Common.h> @@ -43,6 +44,11 @@ #include <vector> #include <functional> +namespace langutil +{ +class Scanner; +} + namespace dev { @@ -57,7 +63,6 @@ namespace solidity { // forward declarations -class Scanner; class ASTNode; class ContractDefinition; class FunctionDefinition; @@ -65,7 +70,6 @@ class SourceUnit; class Compiler; class GlobalContext; class Natspec; -class Error; class DeclarationContainer; /** @@ -100,7 +104,7 @@ public: m_errorReporter(m_errorList) {} /// @returns the list of errors that occurred during parsing and type checking. - ErrorList const& errors() const { return m_errorReporter.errors(); } + langutil::ErrorList const& errors() const { return m_errorReporter.errors(); } /// @returns the current state. State state() const { return m_stackState; } @@ -174,7 +178,7 @@ public: std::map<std::string, unsigned> sourceIndices() const; /// @returns the previously used scanner, useful for counting lines during error reporting. - Scanner const& scanner(std::string const& _sourceName) const; + langutil::Scanner const& scanner(std::string const& _sourceName) const; /// @returns the parsed source unit with the supplied name. SourceUnit const& ast(std::string const& _sourceName) const; @@ -182,7 +186,7 @@ public: /// Helper function for logs printing. Do only use in error cases, it's quite expensive. /// line and columns are numbered starting from 1 with following order: /// start line, start column, end line, end column - std::tuple<int, int, int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const; + std::tuple<int, int, int, int> positionFromSourceLocation(langutil::SourceLocation const& _sourceLocation) const; /// @returns a list of the contract names in the sources. std::vector<std::string> contractNames() const; @@ -248,7 +252,7 @@ private: /// The state per source unit. Filled gradually during parsing. struct Source { - std::shared_ptr<Scanner> scanner; + std::shared_ptr<langutil::Scanner> scanner; std::shared_ptr<SourceUnit> ast; bool isLibrary = false; void reset() { scanner.reset(); ast.reset(); } @@ -345,8 +349,8 @@ private: /// This is updated during compilation. std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes; std::map<std::string const, Contract> m_contracts; - ErrorList m_errorList; - ErrorReporter m_errorReporter; + langutil::ErrorList m_errorList; + langutil::ErrorReporter m_errorReporter; bool m_metadataLiteralSources = false; State m_stackState = Empty; }; diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 1f20366e..de6b2ce5 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -35,6 +35,7 @@ using namespace std; using namespace dev; using namespace dev::eth; +using namespace langutil; using namespace dev::solidity; GasEstimator::ASTGasConsumptionSelfAccumulated GasEstimator::structuralEstimation( diff --git a/libsolidity/interface/SourceReferenceFormatter.cpp b/libsolidity/interface/SourceReferenceFormatter.cpp index 9e2c988e..d727afbe 100644 --- a/libsolidity/interface/SourceReferenceFormatter.cpp +++ b/libsolidity/interface/SourceReferenceFormatter.cpp @@ -25,6 +25,7 @@ #include <liblangutil/Exceptions.h> using namespace std; +using namespace langutil; namespace dev { diff --git a/libsolidity/interface/SourceReferenceFormatter.h b/libsolidity/interface/SourceReferenceFormatter.h index 281a4bdc..7dea5254 100644 --- a/libsolidity/interface/SourceReferenceFormatter.h +++ b/libsolidity/interface/SourceReferenceFormatter.h @@ -25,7 +25,12 @@ #include <ostream> #include <sstream> #include <functional> -#include <liblangutil/SourceLocation.h> + +namespace langutil +{ +struct SourceLocation; +class Scanner; +} namespace dev { @@ -35,13 +40,12 @@ struct Exception; // forward namespace solidity { -class Scanner; // forward class CompilerStack; // forward class SourceReferenceFormatter { public: - using ScannerFromSourceNameFun = std::function<Scanner const&(std::string const&)>; + using ScannerFromSourceNameFun = std::function<langutil::Scanner const&(std::string const&)>; explicit SourceReferenceFormatter( std::ostream& _stream, @@ -52,7 +56,7 @@ public: {} /// Prints source location if it is given. - void printSourceLocation(SourceLocation const* _location); + void printSourceLocation(langutil::SourceLocation const* _location); void printExceptionInformation(Exception const& _exception, std::string const& _name); static std::string formatExceptionInformation( @@ -69,7 +73,7 @@ public: } private: /// Prints source name if location is given. - void printSourceName(SourceLocation const* _location); + void printSourceName(langutil::SourceLocation const* _location); std::ostream& m_stream; ScannerFromSourceNameFun m_scannerFromSourceName; diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index c8b03a94..291a1071 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -31,6 +31,7 @@ using namespace std; using namespace dev; +using namespace langutil; using namespace dev::solidity; namespace { @@ -411,7 +412,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) Json::Value outputSelection = settings.get("outputSelection", Json::Value()); m_compilerStack.setRequestedContractNames(requestedContractNames(outputSelection)); - auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compilerStack.scanner(_sourceName); }; + auto scannerFromSourceName = [&](string const& _sourceName) -> Scanner const& { return m_compilerStack.scanner(_sourceName); }; try { |