mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Remove unused interfaces from CompilerStack
This commit is contained in:
		
							parent
							
								
									887823dca6
								
							
						
					
					
						commit
						fa5a7efb45
					
				| @ -106,12 +106,6 @@ bool CompilerStack::addSource(string const& _name, string const& _content, bool | |||||||
| 	return existed; | 	return existed; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CompilerStack::setSource(string const& _sourceCode) |  | ||||||
| { |  | ||||||
| 	reset(); |  | ||||||
| 	addSource("", _sourceCode); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool CompilerStack::parse() | bool CompilerStack::parse() | ||||||
| { | { | ||||||
| 	//reset
 | 	//reset
 | ||||||
| @ -252,23 +246,11 @@ bool CompilerStack::analyze() | |||||||
| 		return false; | 		return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool CompilerStack::parse(string const& _sourceCode) |  | ||||||
| { |  | ||||||
| 	setSource(_sourceCode); |  | ||||||
| 	return parse(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool CompilerStack::parseAndAnalyze() | bool CompilerStack::parseAndAnalyze() | ||||||
| { | { | ||||||
| 	return parse() && analyze(); | 	return parse() && analyze(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool CompilerStack::parseAndAnalyze(std::string const& _sourceCode) |  | ||||||
| { |  | ||||||
| 	setSource(_sourceCode); |  | ||||||
| 	return parseAndAnalyze(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| vector<string> CompilerStack::contractNames() const | vector<string> CompilerStack::contractNames() const | ||||||
| { | { | ||||||
| 	if (m_stackState < AnalysisSuccessful) | 	if (m_stackState < AnalysisSuccessful) | ||||||
| @ -300,11 +282,6 @@ bool CompilerStack::compile(bool _optimize, unsigned _runs, map<string, h160> co | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool CompilerStack::compile(string const& _sourceCode, bool _optimize, unsigned _runs) |  | ||||||
| { |  | ||||||
| 	return parseAndAnalyze(_sourceCode) && compile(_optimize, _runs); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void CompilerStack::link() | void CompilerStack::link() | ||||||
| { | { | ||||||
| 	for (auto& contract: m_contracts) | 	for (auto& contract: m_contracts) | ||||||
|  | |||||||
| @ -97,32 +97,23 @@ public: | |||||||
| 	void setRemappings(std::vector<std::string> const& _remappings); | 	void setRemappings(std::vector<std::string> const& _remappings); | ||||||
| 
 | 
 | ||||||
| 	/// Resets the compiler to a state where the sources are not parsed or even removed.
 | 	/// Resets the compiler to a state where the sources are not parsed or even removed.
 | ||||||
|  | 	/// Sets the state to SourcesSet if @a _keepSources is true, otherwise to Empty.
 | ||||||
|  | 	/// All settings, with the exception of remappings, are reset.
 | ||||||
| 	void reset(bool _keepSources = false); | 	void reset(bool _keepSources = false); | ||||||
| 
 | 
 | ||||||
| 	/// Adds a source object (e.g. file) to the parser. After this, parse has to be called again.
 | 	/// Adds a source object (e.g. file) to the parser. After this, parse has to be called again.
 | ||||||
| 	/// @returns true if a source object by the name already existed and was replaced.
 | 	/// @returns true if a source object by the name already existed and was replaced.
 | ||||||
| 	void addSources(StringMap const& _nameContents, bool _isLibrary = false) |  | ||||||
| 	{ |  | ||||||
| 		for (auto const& i: _nameContents) addSource(i.first, i.second, _isLibrary); |  | ||||||
| 	} |  | ||||||
| 	bool addSource(std::string const& _name, std::string const& _content, bool _isLibrary = false); | 	bool addSource(std::string const& _name, std::string const& _content, bool _isLibrary = false); | ||||||
| 	void setSource(std::string const& _sourceCode); |  | ||||||
| 	/// Parses all source units that were added
 | 	/// Parses all source units that were added
 | ||||||
| 	/// @returns false on error.
 | 	/// @returns false on error.
 | ||||||
| 	bool parse(); | 	bool parse(); | ||||||
| 	/// Sets the given source code as the only source unit apart from standard sources and parses it.
 | 	/// Performs the analysis steps (imports, scopesetting, syntaxCheck, referenceResolving,
 | ||||||
| 	/// @returns false on error.
 |  | ||||||
| 	bool parse(std::string const& _sourceCode); |  | ||||||
| 	/// performs the analyisis steps (imports, scopesetting, syntaxCheck, referenceResolving,
 |  | ||||||
| 	///  typechecking, staticAnalysis) on previously set sources
 | 	///  typechecking, staticAnalysis) on previously set sources
 | ||||||
| 	/// @returns false on error.
 | 	/// @returns false on error.
 | ||||||
| 	bool analyze(); | 	bool analyze(); | ||||||
| 	/// Parses and analyzes all source units that were added
 | 	/// Parses and analyzes all source units that were added
 | ||||||
| 	/// @returns false on error.
 | 	/// @returns false on error.
 | ||||||
| 	bool parseAndAnalyze(); | 	bool parseAndAnalyze(); | ||||||
| 	/// Sets the given source code as the only source unit apart from standard sources and parses and analyzes it.
 |  | ||||||
| 	/// @returns false on error.
 |  | ||||||
| 	bool parseAndAnalyze(std::string const& _sourceCode); |  | ||||||
| 	/// @returns a list of the contract names in the sources.
 | 	/// @returns a list of the contract names in the sources.
 | ||||||
| 	std::vector<std::string> contractNames() const; | 	std::vector<std::string> contractNames() const; | ||||||
| 
 | 
 | ||||||
| @ -133,9 +124,6 @@ public: | |||||||
| 		unsigned _runs = 200, | 		unsigned _runs = 200, | ||||||
| 		std::map<std::string, h160> const& _libraries = std::map<std::string, h160>{} | 		std::map<std::string, h160> const& _libraries = std::map<std::string, h160>{} | ||||||
| 	); | 	); | ||||||
| 	/// Parses and compiles the given source code.
 |  | ||||||
| 	/// @returns false on error.
 |  | ||||||
| 	bool compile(std::string const& _sourceCode, bool _optimize = false, unsigned _runs = 200); |  | ||||||
| 
 | 
 | ||||||
| 	/// @returns the assembled object for a contract.
 | 	/// @returns the assembled object for a contract.
 | ||||||
| 	eth::LinkerObject const& object(std::string const& _contractName = "") const; | 	eth::LinkerObject const& object(std::string const& _contractName = "") const; | ||||||
| @ -202,6 +190,7 @@ public: | |||||||
| 	/// @returns the list of errors that occured during parsing and type checking.
 | 	/// @returns the list of errors that occured during parsing and type checking.
 | ||||||
| 	ErrorList const& errors() { return m_errorReporter.errors(); } | 	ErrorList const& errors() { return m_errorReporter.errors(); } | ||||||
| 
 | 
 | ||||||
|  | 	/// @returns the current state.
 | ||||||
| 	State state() const { return m_stackState; } | 	State state() const { return m_stackState; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  | |||||||
| @ -65,7 +65,9 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void expectNatspecError(std::string const& _code) | 	void expectNatspecError(std::string const& _code) | ||||||
| 	{ | 	{ | ||||||
| 		BOOST_CHECK(!m_compilerStack.parseAndAnalyze(_code)); | 		m_compilerStack.reset(false); | ||||||
|  | 		m_compilerStack.addSource("", "pragma solidity >=0.0;\n" + _code); | ||||||
|  | 		BOOST_CHECK(!m_compilerStack.parseAndAnalyze()); | ||||||
| 		BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); | 		BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user